Add filename components in Checkpoint#2498
Merged
vfdev-5 merged 10 commits intopytorch:masterfrom Mar 9, 2022
Merged
Conversation
vfdev-5
reviewed
Mar 8, 2022
vfdev-5
reviewed
Mar 8, 2022
Collaborator
vfdev-5
left a comment
There was a problem hiding this comment.
Looks good to me, just a nit about refactored function name
vfdev-5
approved these changes
Mar 9, 2022
Collaborator
vfdev-5
left a comment
There was a problem hiding this comment.
LGTM, thanks @sdesrozis !
vfdev-5
reviewed
May 12, 2022
Comment on lines
+550
to
+564
| with tempfile.TemporaryDirectory() as tmpdirname: | ||
| handler = ModelCheckpoint(tmpdirname, 'myprefix', n_saved=None, create_dir=True) | ||
|
|
||
| model = torch.nn.Linear(3, 3) | ||
| optimizer = torch.optim.SGD(model.parameters(), lr=1e-3) | ||
|
|
||
| to_save = {"weights": model, "optimizer": optimizer} | ||
|
|
||
| trainer.add_event_handler(Events.EPOCH_COMPLETED(every=2), handler, to_save) | ||
| trainer.run(torch.randn(10, 1), 5) | ||
|
|
||
| to_load = to_save | ||
| checkpoint_fp = Path(tmpdirname) / 'myprefix_checkpoint_40.pt' | ||
| checkpoint = torch.load(checkpoint_fp) | ||
| Checkpoint.load_objects(to_load=to_load, checkpoint=checkpoint) |
Collaborator
There was a problem hiding this comment.
@sdesrozis this example is not working:
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
Input In [2], in <cell line: 10>()
21 to_load = to_save
22 # load checkpoint myprefix_checkpoint_40.pt
---> 23 checkpoint.load_objects(to_load=to_load, global_step=40)
TypeError: load_objects() missing 1 required positional argument: 'checkpoint'
vfdev-5
reviewed
May 12, 2022
| import torch | ||
|
|
||
| from ignite.engine import Engine, Events | ||
| from ignite.handlers import ModelCheckpoint, Checkpoint |
Collaborator
There was a problem hiding this comment.
We can also remove unused Checkpoint
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes #2480
Description:
Check list: