-
Notifications
You must be signed in to change notification settings - Fork 3.6k
docs(LightningModule): update docs for .training
mode in loops
#20716
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
base: master
Are you sure you want to change the base?
docs(LightningModule): update docs for .training
mode in loops
#20716
Conversation
Update the pseudocode of validation loop according to Lightning-AI#18951: > when the validation loop ends, and before switching to training, it > restores the `.training mode` on all submodules to what it was before. and add a corresponding note to `{validate,test,predict}_step`. Additional changes: * Fix incorrect comment in `lightning_module.rst` that `trainer.test(model)` loads the best weights.
This pull request has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. If you need further help see our docs: https://lightning.ai/docs/pytorch/latest/generated/CONTRIBUTING.html#pull-request or ask the assistance of a core contributor here or on Discord. Thank you for your contributions. |
cc @Borda |
When the :meth:`validation_step` is called, the model has been put in eval mode | ||
and PyTorch gradients have been disabled. At the end of validation, | ||
the model goes back to training mode and gradients are enabled. | ||
When the :meth:`validation_step` is called, the model has been put |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for completeness can we add a inverse note to the training step, e.g. that when train_step
is called, the model has NOT been put into train mode and that it is something the user should be aware of
Co-authored-by: Nicki Skafte Detlefsen <skaftenicki@gmail.com>
Related to #18951 (comment).
Update the pseudocode of validation loop according to #18951:
and add a corresponding note to
{validation,test,predict}_step
since they exhibit this behavior as can be seen in the following snippet:@awaelchli Can you please confirm that this is the intended (default) behavior of the loops?
Additional changes:
lightning_module.rst
thattrainer.test(model)
loads the best weights. According to the docs, Ifckpt_path=None
and the model instance was passed, use the current weights.What does this PR do?
Fixes #<issue_number>
Before submitting
PR review
Anyone in the community is welcome to review the PR.
Before you start reviewing, make sure you have read the review guidelines. In short, see the following bullet-list:
Reviewer checklist
📚 Documentation preview 📚: https://pytorch-lightning--20716.org.readthedocs.build/en/20716/