-
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 |
@@ -286,6 +286,9 @@ Under the hood, Lightning does the following (pseudocode): | |||
# ... | |||
|
|||
if validate_at_some_point: | |||
# capture .training mode of every submodule | |||
capture_training_mode() |
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.
Can we add some examples of what the capture_training_mode
and later restore_training_mode
us used for? Now it's a bit confusing since you declare/use a cute function but a new function...
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.
@Borda I am thinking of adding a note in the docs instead of introducing these functions in the pseudocode of the validation loop. The take home message should be that Lightning takes care of ensuring that layers set in eval mode by user remain in eval mode.
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/