-
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
Keep track of the best model's path saved by ModelCheckpoint #1799
Merged
williamFalcon
merged 15 commits into
Lightning-AI:master
from
kepler:feature/keep-track-of-best-model
May 31, 2020
Merged
Changes from 9 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
ed3e6f3
Add an additional attribute to ModelCheckpoint to keep track of the b…
kepler 33ea275
Add small description and usage example to docs
kepler 5fe9a58
Fix PEP8 issues
kepler 7a92c00
Fix doctest example
kepler 1434249
Fix expected output in doctest
kepler 648c152
Apply suggestions from code review
Borda 8c59480
Show example as code block instead of doctest
kepler 0ee63a9
Apply suggestions from code review
Borda 24c27a0
Update CHANGELOG.md
kepler 3f4901d
Rename `ModelCheckpoint.best` to `ModelCheckpoint.best_model_score`
kepler 5a7ea43
Merge branch 'master' into feature/keep-track-of-best-model
kepler f09372f
Update pytorch_lightning/trainer/training_io.py
kepler bc2baad
Apply suggestions from code review
kepler ac36651
Add warning when loading checkpoint from an old version
kepler 7b8a633
Merge branch 'master' into feature/keep-track-of-best-model
kepler File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
here the best means
best_score
? otherwise, it is a bit confusing to havebest
andbest_model
pls add types to the init 🐰
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.
Yes,
self.best
is the best "monitored quantity". But that's existing naming. Changing it will break backwards compatibility. If that's OK, I can surely rename it. Otherwise,best_model
could bebest_model_path
. I usedbest_model
to keep consistency with the existingkth_best_model
attribute.As for type hints, there's no changes to the arguments. Where specifically would I add them?
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.
@PyTorchLightning/core-contributors are we fine to rename
best
>>best_score
?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 would prefer it (
best_score
), but if we do that we need to provide our users with a utility to upgrade their checkpoints (basically switchbest
tobest_score
) and temporarily have a warning which catches old checkpoints at load time and alerts users of the utility to convert. it's a very simple utility but we should provide it for our users if we move forward with this.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.
@jeremyjordan you mean to keep compatible with past saved checkpoint which contains
best
? That shall be simple, in loading, we will mapbest
>>best_score
... and yes we shall wrap the deprecatedbest
with some warning :]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.
OK, I renamed
best
tobest_model_score
andbest_model
tobest_model_path
, since havingbest_score
andbest_model
would still be a bit confusing (IMHO). To keep consistency, I also renamedkth_best_model
tokth_best_model_path
.I added properties for
best
andkth_best_model
that log a deprecation warning and return the correct value.When loading a checkpoint, if it's in an old format, the value for
best
is simply assigned tobest_model_score
. In my opinion, adding a warning in this part will not really help the user, as there's not much they can do.Let me know of any further changes.