Loading pretrained parameters to a model

I have created a model, trained it, evaluated and saved with

torch.save(model.state_dict(), 'pathToSavedModel')

If I create the same model in a different .py file, how can I load the pretrained parameters from an old model to new one so I can evaluate it directly ?
Documentation on torch.load does not give me any insight and I could not relate other discussions to my case.

You can load the state_dict using:

model = YourModel()
model.load_state_dict(torch.load('pathToSavedModel'))

Have a look at the Serialization semantics for more information.

1 Like

It worked ! Thank you kind sir, you are da real MVP !