Problems with creating my first Neural Net using PyTorch

After watching Lecture 3 and reading through fastbook chapter 4, I decided to create a simple Neural Net using PyTorch (Building my first Neural Net with Pytorch | Kaggle). Apart from the book I used this tutorial by PyTroch (Deep Learning with PyTorch: A 60 Minute Blitz — PyTorch Tutorials 2.0.0+cu117 documentation).

Now I have run into a problem: During training the loss decreases significantly, but the training accuracy stays exactly the same. I wrote a Stack Overflow post containing a little more details here: python - Neural Net: Loss decreasing, but accuracy stays exactly the same - Stack Overflow

Any help is greatly appreciated!

Hello

When computing the accuracy you made a little mistake:
_, predicted = torch.max(outputs.data, 1) here you are using the outputs of the forward pass.
It should be:
_, predicted = torch.max(output.data, 1)
have a good day!

3 Likes

Thank you! Sometimes a little mistake can change so much :slight_smile:

1 Like