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

model.train(False) affects gradient tracking? #2230

Closed
MaverickMeerkat opened this issue Mar 2, 2023 · 3 comments · Fixed by #2372
Closed

model.train(False) affects gradient tracking? #2230

MaverickMeerkat opened this issue Mar 2, 2023 · 3 comments · Fixed by #2372
Assignees
Labels
docathon-h1-2023 A label for the docathon in H1 2023 easy intro question

Comments

@MaverickMeerkat
Copy link

MaverickMeerkat commented Mar 2, 2023

In this tutorial here it says in the comment that "# We don't need gradients on to do reporting". From what I understand the train flag only affects layers such as dropout and batch-normalization. Does it also affect gradient calculations, or is this comment wrong?

# We don't need gradients on to do reporting

cc @suraj813

@chedatomasz
Copy link

This comment, and the accompanying code, is wrong. A more correct pattern is shown at https://pytorch.org/tutorials/beginner/basics/optimization_tutorial.html#full-implementation, although this one misses the train/eval switches and thus does not generalize to models with batchnorm and dropout.

@chedatomasz
Copy link

Related issues: #2083 #1756 #208

@svekars svekars added easy docathon-h1-2023 A label for the docathon in H1 2023 labels May 31, 2023
@JoseLuisC99
Copy link
Contributor

/assigntome

carljparker pushed a commit that referenced this issue Jun 1, 2023
* refactored train loop in trainingyt.py, resolves issue #2230

* Simplified numpy function call, resolves issue #1038
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docathon-h1-2023 A label for the docathon in H1 2023 easy intro question
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants