-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
Count number of modules in train/eval mode in ModelSummary #20159
Conversation
for more information, see https://pre-commit.ci
⚡ Required checks status: All passing 🟢Groups summary🟢 pytorch_lightning: Tests workflowThese checks are required after the changes to 🟢 pytorch_lightning: Azure GPU
These checks are required after the changes to 🟢 pytorch_lightning: Benchmarks
These checks are required after the changes to 🟢 pytorch_lightning: Docs
These checks are required after the changes to 🟢 mypy
These checks are required after the changes to 🟢 installThese checks are required after the changes to Thank you for your contribution! 💜
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #20159 +/- ##
=========================================
- Coverage 89% 81% -8%
=========================================
Files 267 264 -3
Lines 23050 23008 -42
=========================================
- Hits 20552 18601 -1951
- Misses 2498 4407 +1909 |
What does this PR do?
Fixes #19820
Fixes #20128
This PR adds two rows to the model summary that count how many modules are in train and how many are in eval model. The issues linked above raised concern that it is not visible enough when models are in eval mode (accidentally). Printing the explicit count for each mode should raise awareness:
To see which modules are in train/eval mode, the user can look at the summary table or expand it to show all modules using
ModelSummary(max_depth=-1)
.Example:
Output:
New are the two rows at the bottom that count the modules in train/eval mode.
Alternatives
#19820 initially proposed to print a warning. However, that would lead to false positives when doing finetuning, and so I opted for the info in the model summary (which is on by default in the Trainer).
📚 Documentation preview 📚: https://pytorch-lightning--20159.org.readthedocs.build/en/20159/
cc @Borda @awaelchli