Skip to content
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

Deprecate the default EarlyStopping callback monitor value #7907

Conversation

bamblebam
Copy link
Contributor

@bamblebam bamblebam commented Jun 9, 2021

What does this PR do?

Removes the default value for the monitor argument from the early stopping callback. Also adds the deprecation message.
Fixes #7894

Before submitting

  • Was this discussed/approved via a GitHub issue? (not for typos and docs)
  • Did you read the contributor guideline, Pull Request section?
  • Did you make sure your PR does only one thing, instead of bundling different changes together?
  • Did you make sure to update the documentation with your changes? (if necessary)
  • Did you write any new necessary tests? (not for typos and docs)
  • Did you verify new and existing tests pass locally with your changes?
  • Did you update the CHANGELOG? (not for typos, docs, test updates, or internal minor changes/refactorings)

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:

  • Is this pull request ready for review? (if not, please submit in draft mode)
  • Check that all items from Before submitting are resolved
  • Make sure the title is self-explanatory and the description concisely explains the PR
  • Add labels and milestones (and optionally projects) to the PR so it can be classified

Did you have fun?

Make sure you had fun coding 🙃

@pep8speaks
Copy link

pep8speaks commented Jun 9, 2021

Hello @bamblebam! Thanks for updating this PR.

There are currently no PEP 8 issues detected in this Pull Request. Cheers! 🍻

Comment last updated at 2021-06-10 19:12:24 UTC

@codecov
Copy link

codecov bot commented Jun 9, 2021

Codecov Report

Merging #7907 (8cfe43e) into master (ec4f885) will decrease coverage by 1%.
The diff coverage is 100%.

@@           Coverage Diff           @@
##           master   #7907    +/-   ##
=======================================
- Coverage      88%     88%    -1%     
=======================================
  Files         204     200     -4     
  Lines       13667   12839   -828     
=======================================
- Hits        12047   11237   -810     
+ Misses       1620    1602    -18     

Copy link
Contributor

@ananthsub ananthsub left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for working on this @bamblebam !

please add a test here: https://github.com/PyTorchLightning/pytorch-lightning/blob/master/tests/deprecated_api/test_remove_1-6.py

which instantiates an EarlyStopping callback without setting the monitor to confirm the warning appears as expected

pytorch_lightning/callbacks/early_stopping.py Outdated Show resolved Hide resolved
pytorch_lightning/callbacks/early_stopping.py Show resolved Hide resolved
@bamblebam
Copy link
Contributor Author

@ananthsub can you tell me why my test is failing?

Copy link
Contributor

@ananthsub ananthsub left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Be sure to add a CHANGELOG entry to the deprecated section of 1.4.0 with this PR:

See here for examples
https://github.com/PyTorchLightning/pytorch-lightning/blob/master/CHANGELOG.md#deprecated

@bamblebam
Copy link
Contributor Author

bamblebam commented Jun 10, 2021

Hey I updated the changelog.
@ananthsub should I mark this as ready for review?

CHANGELOG.md Outdated
Comment on lines 173 to 174
- Deprecated `monitor` argument in EarlyStopping will be required. ([#7907](https://github.com/PyTorchLightning/pytorch-lightning/pull/7907))

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- Deprecated `monitor` argument in EarlyStopping will be required. ([#7907](https://github.com/PyTorchLightning/pytorch-lightning/pull/7907))
- Deprecated default value of `monitor` argument in EarlyStopping callback to enforce `monitor` as a required argument ([#7907](https://github.com/PyTorchLightning/pytorch-lightning/pull/7907))

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

@ananthsub
Copy link
Contributor

yes this is ready for review

@ananthsub ananthsub marked this pull request as ready for review June 10, 2021 17:55
@@ -120,6 +119,13 @@ def __init__(
torch_inf = torch.tensor(np.Inf)
self.best_score = torch_inf if self.monitor_op == torch.lt else -torch_inf

if monitor is None:
rank_zero_deprecation(
"The `monitor` argument will be required to be set starting in v1.6."
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"The `monitor` argument will be required to be set starting in v1.6."
"The `EarlyStoppinf(monitor)` argument will be required starting in v1.6."

@carmocca carmocca added this to the v1.4 milestone Jun 10, 2021
@carmocca carmocca added the feature Is an improvement or enhancement label Jun 10, 2021
@carmocca carmocca changed the title Fixes #7894 Removing early stopping callback monitor default value Deprecate the default EarlyStopping callback monitor value Jun 10, 2021
Copy link
Contributor

@awaelchli awaelchli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we may want to consider making the change to our tests wherever the argument is missing.

CHANGELOG.md Outdated
Comment on lines 173 to 174
- Deprecated `monitor` argument in EarlyStopping will be required. ([#7907](https://github.com/PyTorchLightning/pytorch-lightning/pull/7907))

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

"The `monitor` argument will be required to be set starting in v1.6."
" For backward compatibility, setting this to `early_stop_on`."
)
self.monitor = monitor or 'early_stop_on'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
self.monitor = monitor or 'early_stop_on'
self.monitor = monitor or "early_stop_on"

double quotes everywhere else it seems

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

alright I will do the change

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can just click the button "commit suggestion" here on github below my message. so you don't have to manually commit it. what you prefer!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note quoting will get standardized with #7783

@bamblebam
Copy link
Contributor Author

@awaelchli can you tell me why the tests might be failing?

@awaelchli awaelchli requested a review from ananthsub June 10, 2021 22:44
@awaelchli awaelchli added the ready PRs ready to be merged label Jun 10, 2021
Copy link
Contributor

@ananthsub ananthsub left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

great job @bamblebam !

@ananthsub ananthsub merged commit 8b73869 into Lightning-AI:master Jun 11, 2021
@bamblebam
Copy link
Contributor Author

Thanks for guiding me through this :)

speediedan pushed a commit to speediedan/lightning that referenced this pull request Jun 11, 2021
…ng-AI#7907)

* removed monitor default value and added depreceation message

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* format change

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* requested changes

* added test

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* format changes

* typehint change

* Update CHANGELOG.md

* requested changes

* regex

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Adrian Wälchli <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
callback feature Is an improvement or enhancement ready PRs ready to be merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Remove default monitor value from the EarlyStopping callback
5 participants