PacktPublishing / Deep-Learning-with-PyTorch

Deep Learning with PyTorch, published by Packt

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Bugs and improvements Chapter 2

BCJuan opened this issue · comments

Hi,

First of all: nice work. I am following your book to learn Pytorch.

The point is that, as also seen in #3 , there are some errors in the code. If you find it appropriate, I can make the changes and make a pull request.

The bugs are:

  • In function loss_fn: IndexError: invalid index of a 0-dim tensor. Use tensor.item() to convert a 0-dim tensor to a Python number
    simply change loss.data[0] by loss.item()

  • In function plot_variable you check if variable is type Variable but indeed they are type tensor. So solution would be to check is they are torch.Tensor.

  • As I cloned the repo the panda image is in ìmagesso the linepanda = np.array(Image.open('../data/images/panda.jpg').resize((224,224)))gives.FileNotFoundError: [Errno 2] No such file or directory: '../data/images/panda.jpg'Basically change the path to'../images/B09301_03_12.jpg'`

Also this is not a bug but the dataset and dataloaders class could be exemplified by sampling a batch and visualizing.

That's all.

Thank you for everything.

Please reopen if the issue still persists.