-
By default, the best model and the last model are saved by catalyst as checkpoints. For example, I have the following files in the checkpoints folder:
I then use the following code to read the checkpoint. checkpoint = utils.load_checkpoint(path=os.path.join(model_dir, 'model.best.pth'))
checkpoint.keys()
# the output is: odict_keys(['model.0.weight', 'model.0.bias', 'model.2.weight', 'model.2.bias', 'model.4.weight', 'model.4.bias']) The obtained Now the question is how I can restore the network model with Is there any method in |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Sorry for my ignorance.. In the model-only saving mode, the model.load_state_dict(torch.load(os.path.join(model_dir, 'model.best.pth')) |
Beta Was this translation helpful? Give feedback.
Sorry for my ignorance..
In the model-only saving mode, the
model.*.pth
file contains exactly thestate_dict
of a model in pytorch. Supposing we have defined ourmodel
, simply do it like this to restore the trained model: