-
Notifications
You must be signed in to change notification settings - Fork 3.6k
[1/2] Add support for early stopping during training epoch end #6944
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
[1/2] Add support for early stopping during training epoch end #6944
Conversation
Codecov Report
@@ Coverage Diff @@
## master #6944 +/- ##
=======================================
- Coverage 91% 87% -4%
=======================================
Files 199 199
Lines 12783 12805 +22
=======================================
- Hits 11659 11160 -499
- Misses 1124 1645 +521 |
ananthsub
left a comment
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.
this is blocked on #6921 as the hook ordering is off, meaning we can't access the trainer's logger metrics as expected. the callback for on_train_epoch_end runs before training_epoch_end in the lightning module
04ae832 to
dc55fd5
Compare
|
Hello @ananthsub! Thanks for updating this PR. There are currently no PEP 8 issues detected in this Pull Request. Cheers! 🍻 Comment last updated at 2021-04-28 08:59:19 UTC |
awaelchli
left a comment
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.
In a follow up PR, we can remove
Have you already tried it? Does it go without complications?
|
@awaelchli see #7069 for the followup. |
tchaton
left a comment
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 !
| def _epoch_end(self) -> None: | ||
| losses = [8, 4, 2, 3, 4, 5, 8, 10] | ||
| val_loss = losses[self.current_epoch] | ||
| self.log('abc', torch.tensor(val_loss)) |
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.
Should we log with different keys on val/train for the test ?
| "callbacks, expected_stop_epoch, check_on_train_epoch_end, accelerator, num_processes", | ||
| [ | ||
| ([EarlyStopping(monitor='abc'), EarlyStopping(monitor='cba', patience=3)], 3, None, 1), | ||
| ([EarlyStopping(monitor='abc'), EarlyStopping(monitor='cba', patience=3)], 3, False, None, 1), |
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.
@carmocca id we simplify each EarlyStop we can fit to single line :P
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.
What do you mean?
1a48461 to
a59c78a
Compare
| ([EarlyStopping('abc'), EarlyStopping('cba', patience=3)], 3, False, None, 1), | ||
| ([EarlyStopping('cba', patience=3), EarlyStopping('abc')], 3, False, None, 1), | ||
| pytest.param([EarlyStopping('abc'), EarlyStopping('cba', patience=3)], 3, False, 'ddp_cpu', 2, **_NO_WIN), | ||
| pytest.param([EarlyStopping('cba', patience=3), EarlyStopping('abc')], 3, False, 'ddp_cpu', 2, **_NO_WIN), | ||
| ([EarlyStopping('abc', **_ES_CHECK), EarlyStopping('cba', **_ES_CHECK_P3)], 3, True, None, 1), | ||
| ([EarlyStopping('cba', **_ES_CHECK_P3), EarlyStopping('abc', **_ES_CHECK)], 3, True, None, 1), | ||
| pytest.param([EarlyStopping('abc', **_ES_CHECK), | ||
| EarlyStopping('cba', **_ES_CHECK_P3)], 3, True, 'ddp_cpu', 2, **_NO_WIN), | ||
| pytest.param([EarlyStopping('cba', **_ES_CHECK_P3), | ||
| EarlyStopping('abc', **_ES_CHECK)], 3, True, 'ddp_cpu', 2, **_NO_WIN), |
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.
I mean this @carmocca from #6944 (comment)
What does this PR do?
Fixes #7033
Part 1
In a follow up PR, we can remove https://github.com/PyTorchLightning/pytorch-lightning/blob/5bd3cd5f712b65d38812b27cf957261bb06b83c5/pytorch_lightning/trainer/training_loop.py#L152-L160
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 🙃