-
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
Move training_output
validation to after train_step_end
#7868
Conversation
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.
Thanks for the fix! I agree, we should run the check after training_step_end to allow for this
Codecov Report
@@ Coverage Diff @@
## master #7868 +/- ##
=======================================
- Coverage 93% 87% -6%
=======================================
Files 202 202
Lines 13123 13123
=======================================
- Hits 12156 11402 -754
- Misses 967 1721 +754 |
Do you want to add a test similar to this one for order? |
Hello @kandluis! Thanks for updating this PR. There are currently no PEP 8 issues detected in this Pull Request. Cheers! 🍻 Comment last updated at 2021-06-08 00:06:29 UTC |
for more information, see https://pre-commit.ci
Added a functional test for this behavior - let me know if you prefer I explicitly mock out the calls and track them as in the unit test you suggested. |
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.
LGTM !
* move validation to after aggregation * changelog * add test for training_step_end * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> (cherry picked from commit f9fccdf)
* move validation to after aggregation * changelog * add test for training_step_end * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> (cherry picked from commit f9fccdf)
What does this PR do?
See comments in https://github.com/PyTorchLightning/pytorch-lightning/pull/7779/files#r646750001.
We have a downstream
LightningModule
that does not conform to these expectations. It defines atrainign_step_end
which returns theloss
(after accumulating partial outputs fromtraining_step
) but where eachtraining_step
does not return a loss or aMapping
containing a keyloss
.This still works with automatic optimization since the
training_step_end
function collects the results fromtraining_step
and itself returns atorch.Tensor
corresponding to the loss.So the question is: If I do define
training_step_end
, should I be allowed to not return aloss
fromtraining_step
as long as I return it ontraining_step_end
?Assuming an affirmative to the above, this PR makes it so the validation occurs after
training_step_end.
Before submitting
PR review
Anyone in the community is free to review the PR once the tests have passed.
Before you start reviewing make sure you have read Review guidelines. In short, see the following bullet-list:
Did you have fun?
Make sure you had fun coding 🙃