PacktPublishing/Mastering-PyTorch

Code error and issues in Chapter02/image_captioning_pytorch.ipynb

schinto opened this issue · 1 comments

a) In the forward function of class LSTMModel the parameter capts is used, but
the self.embedding_layer gets caps without the character t

def forward(self, input_features, capts, lens):
        """Decode image feature vectors and generates captions."""
        embeddings = self.embedding_layer(caps)

b) Model training on Mac OS X does only work with num_workers=0.
The data is not loaded when num_workers is larger than 0 as used in the notebook.

# Build data loader
custom_data_loader = get_loader('data_dir/resized_images', 'data_dir/annotations/captions_train2014.json', vocabulary, 
                         transform, 128,
                         shuffle=True, num_workers=2) 

Related PyTorch issues:

c) Proposal of improving the image captioning example in Chapter 2 of the book:

d) I really like the explanation of transfomer models in the YouTube playlist Visual Guide to Transformers Neural Networks, which is more intuitiv compared to the explanation on page 149 "Understanding the transformer model architecture" of the Mastering PyTorch book.

Had the same problem. Now slowly training with num_workers=0.
Anyway, thanks for research about this error of multiprocessing and pytorch in macOS.

In addition, I found some minor error too in chapter 2: the link for downloading the coco annotation captions link is not valid. PIL.Image is slightly changed.