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

Call on_load_checkpoint before loading state_dict #4057

Merged
merged 1 commit into from
Oct 14, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -101,15 +101,16 @@ def restore(self, checkpoint_path: str, on_gpu: bool):
# load model state
rohitgr7 marked this conversation as resolved.
Show resolved Hide resolved
model = self.trainer.get_model()

# load the state_dict on the model automatically
model.load_state_dict(checkpoint['state_dict'])

# give the datamodule a chance to load something
if self.trainer.datamodule is not None:
self.trainer.datamodule.on_load_checkpoint(checkpoint)

# give model a chance to load something
model.on_load_checkpoint(checkpoint)

# load the state_dict on the model automatically
model.load_state_dict(checkpoint['state_dict'])
rohitgr7 marked this conversation as resolved.
Show resolved Hide resolved

if on_gpu:
model.cuda(self.trainer.root_gpu)

Expand Down