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

Default EarlyStopping.check_on_train_epoch_end=True #8286

Merged
merged 3 commits into from
Jul 5, 2021

Conversation

carmocca
Copy link
Contributor

@carmocca carmocca commented Jul 5, 2021

What does this PR do?

After the changes in #7357 (not released yet), this is the safer default value as train_epoch_end will run after validation_end so it is more likely that the monitored value will have been logged. This assumes that most users want to run their ES callback at the end of the epoch and not somewhere in the middle.

Structure BEFORE #7357: running validation at the end of the epoch

on_train_epoch_end()
on_validation_end()
EarlyStopping.run_check()  # `check_on_train_epoch_end=False` by default

Structure AFTER #7357, BEFORE this PR: running validation at the end of the epoch

on_validation_end()
EarlyStopping.run_check()  # `check_on_train_epoch_end=False` by default
on_train_epoch_end()  # If your monitor was logged here, we broke your workflow

Structure AFTER #7357, AFTER this PR: running validation at the end of the epoch

on_validation_end()
on_train_epoch_end()
EarlyStopping.run_check()  # `check_on_train_epoch_end=True` by default

This matches the ModelPruning flag: https://github.com/PyTorchLightning/pytorch-lightning/blob/83039ba4705b02fbb55d5922d15a258a2f041986/pytorch_lightning/callbacks/pruning.py#L74
And one for ModelCheckpoint will be added in a follow-up PR.

Included some very minor typing/test changes

Part of #7724

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?
  • [n/a] Did you make sure to update the documentation with your changes? (if necessary)
  • [n/a] 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

  • 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

@codecov
Copy link

codecov bot commented Jul 5, 2021

Codecov Report

Merging #8286 (83039ba) into master (7b6d0a8) will decrease coverage by 0%.
The diff coverage is 100%.

❗ Current head 83039ba differs from pull request most recent head 1d2170d. Consider uploading reports for the commit 1d2170d to get more accurate results

@@          Coverage Diff           @@
##           master   #8286   +/-   ##
======================================
- Coverage      93%     92%   -0%     
======================================
  Files         212     212           
  Lines       13729   13727    -2     
======================================
- Hits        12752   12683   -69     
- Misses        977    1044   +67     

@carmocca carmocca enabled auto-merge (squash) July 5, 2021 11:26
@carmocca carmocca disabled auto-merge July 5, 2021 11:26
@carmocca carmocca changed the title Change default EarlyStopping.check_on_train_epoch_end to true Default EarlyStopping.check_on_train_epoch_end=True Jul 5, 2021
@carmocca carmocca enabled auto-merge (squash) July 5, 2021 11:27
@carmocca carmocca added the ready PRs ready to be merged label Jul 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
callback ready PRs ready to be merged refactor
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants