-
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
Fix ModelCheckpoints name formatting #3163
Conversation
Hello @carmocca! Thanks for updating this PR. There are currently no PEP 8 issues detected in this Pull Request. Cheers! 🍻 Comment last updated at 2020-09-18 13:13:23 UTC |
Should we add the possibility of modifying these variables to the doc-string? |
Codecov Report
@@ Coverage Diff @@
## master #3163 +/- ##
======================================
- Coverage 91% 91% -0%
======================================
Files 109 109
Lines 8031 8066 +35
======================================
+ Hits 7291 7311 +20
- Misses 740 755 +15 |
which variables do you mean? |
|
With the changes in this PR, one can do: checkpoint_callback = pl.callbacks.ModelCheckpoint(filepath="my/file/path/name")
# Generates checkpoints called "name.ckpt" in my/file/path But if filepath is an existing directory: checkpoint_callback = pl.callbacks.ModelCheckpoint(filepath="my/file/path")
# Generates checkpoints called "epoch={epoch}.ckpt" in my/file/path
# note: this is the previous default behaviour So there is no need of a |
can we have a test for this |
|
self._del_model(self.last_model_path) | ||
self._save_model(filepath, trainer, pl_module) | ||
self.last_model_path = filepath |
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.
can we (in a new PR pls) first rename the model to "oldname.ckpt.backup" before saving the model, and then delete the backup file after save has completed? Otherwise, if a crash happens during save_model, we will have lost the old checkpoint and are only left with a corrupted file for the current.
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.
A new PR based on master or this branch?
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, just a small suggestion after this PR is merged. but it will touch other locations as well, for example topk saving.
I prefer this PR over the one that adds an extra filename parameter. |
The reason I suggested separate |
Regarding this:
This may not be the only intention for the filepath. For instance, the user could also expect the callback to save checkpoints to directory |
I am not against the idea of splitting filepath into dirpath and filename, however, that discussion is out of scope of this PR. Considering that this PR does not change the API, we could merge this and then (possibly?) work on the filepath improvement. |
Anything holding this back? There will be some conflicts with #3320. Should be easy to fix |
Let's process it... |
Just found out this Should be |
yes, pls |
This pull request is now in conflict... :( |
Co-authored-by: Rohit Gupta <rohitgr1998@gmail.com>
Co-authored-by: Rohit Gupta <rohitgr1998@gmail.com>
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 think this is a great improvement. Thanks for your effort.
Please note for the future, this PR has some independent changes that, although they are good to have, they could have been split over multiple PR's.
as mentioned by @ananthsub it is not possible to distinguish between filename and folder, this bug: #3001 Either way, to fix this I don't see a good way that keeps back compatibility. If back compatibility is unavoidable, I feel like now with the v1 release would be a good time to introduce this breaking change. If not, I think we should at least update docs. |
Cant we keep back compat by having filepath (old parameter) and dirpath, filename (new parameters)?
BTW this discussion should continue elsewhere. Maybe in the issue you linked. |
then we can do some bubble up testing to find the existing folder in upstream and create the remaining?
yes, 1.0 is a good place to do it... |
@carmocca mind creating a new issue for this discussion and link it here... |
What does this PR do?
CHECKPOINT_JOIN_CHAR
,variableCHECKPOINT_SUFFIX
sfor customization.Fixes #3125
Fixes #2583
Closes #2584
Before submitting