I have a model with a GAN architecture trained in a kaggle notebook and I want save it and use it in my local environment.The model is trained using GPU P100 but my local machine does not support GUP.
Following code has used to save the model usinf torch.
torch.save(modelG.state_dict(), 'modelG_appl_v1.pt')
This code is used for loading the model.
# Load the model
prediction_model = Generator(62).to('cpu')
prediction_model.load_state_dict(torch.load('../models/modelG_appl_v1.pt', map_location=torch.device('cpu')))
To get predictions
#get prediction
with torch.no_grad():
prediction_model.eval()
predictions, gru_layer= prediction_model(features)
This model loads without any error but it gives wrong pridictions. I have load the same model in the same kaggle notebook and predicted, and it gives correct results. And also I have tried pickle and joblib as well.
I want to know is there any error in this process or suggest a better way to save and load model. I have another XGB model also to save. Suggest a approch for that as well.
Madara Semini is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.