Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] - Loss calculation problem in train-loop #2811

Open
jaggernaut007 opened this issue Mar 26, 2024 · 2 comments
Open

[BUG] - Loss calculation problem in train-loop #2811

jaggernaut007 opened this issue Mar 26, 2024 · 2 comments
Labels
bug core Tutorials of any level of difficulty related to the core pytorch functionality intro

Comments

@jaggernaut007
Copy link

jaggernaut007 commented Mar 26, 2024

Add Link

https://pytorch.org/tutorials/beginner/basics/optimization_tutorial.html

Describe the bug

The loss calculation seems to be wrong. Should we divide the total loss by the number of values of X rather than the number of batches?

The optimiser also seems wrong.

Describe your environment

Running on Google Colab

cc @subramen @albanD

@jmarintur
Copy link
Contributor

Hi @jaggernaut007, are you referring to this line? If that's the case, the loss within the testing loop gives you a single scalar value per batch, and that's what you are accumulating in test_loss. That's why you need to divide after the loop by the number of batches, num_batches.

@jmarintur
Copy link
Contributor

@svekars unless I am wrong, I think we can close this issue.

@svekars svekars added core Tutorials of any level of difficulty related to the core pytorch functionality intro labels May 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug core Tutorials of any level of difficulty related to the core pytorch functionality intro
Projects
None yet
Development

No branches or pull requests

3 participants