Skip to content
This repository has been archived by the owner on Aug 18, 2021. It is now read-only.

How to save and load train model and use it for evaluation #128

Open
j07nikita opened this issue Mar 23, 2019 · 2 comments
Open

How to save and load train model and use it for evaluation #128

j07nikita opened this issue Mar 23, 2019 · 2 comments

Comments

@j07nikita
Copy link

No description provided.

@j07nikita j07nikita changed the title save model use How to save and load train model and use it for evaluation Mar 23, 2019
@dhananjaisharma10
Copy link

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!

@SuMyo
Copy link

SuMyo commented Jan 21, 2020

"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!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants