Issue
i previously saved a model like this:
trainedmodelpath = "model.th"
torch.save({'model': model,
'scaler': scaler,
'encoder': label_encoder,
'config': config_parameters},
trainedmodelpath)
But when i try to load it like this:
PreviousModelPath = "model.th"
TorchLoadedState = torch.load(PreviousModelPath)
TorchLoadedState_Model = TorchLoadedState['model']
model.load_state_dict(TorchLoadedState_Model)
i received this error
*** AttributeError: 'ModelName' object has no attribute 'copy'
Solution
Save model weigths with model.state_dict()
instead:
torch.save({'model': model.state_dict(),
'scaler': scaler,
'encoder': label_encoder,
'config': config_parameters},
trainedmodelpath)
Answered By - joe32140
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.