practical-pytorch
practical-pytorch copied to clipboard
How to save and load train model and use it for evaluation
To save a model, you can use the following snippet:
torch.save(model.state_dict(), "Models/RES50.pth")
Here, I save my model in the directory Models with the name RES50
While evaluation, you can load your model using the following:
model = Neural_Network()
model.load_state_dict(torch.load('Models/RES50.pth'))
Here, I initialized my model and then loaded the parameters of the model RES50 which was lying in the directory Models.
Hope that helps!
"torch.save(model.state_dict(), "Models/RES50.pth")" In that, we need to define the class 'myModel' in order to create 'model' object. Could you please share the script how to define a model class? Thank in advance!