torch model.load_state_dict *** AttributeError: 'ModelName' object has no attribute 'copy'
i previously saved a model like this:
trainedmodelpath = &quot;model.th&quot;
torch.save({'model': model,
            'scaler': scaler,
            'encoder': label_encoder,
            'config': config_parameters},
            trainedmodelpath)

But when i try to load it like this:
PreviousModelPath = &quot;model.th&quot;
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'


Save model weigths with model.state_dict() instead:
torch.save({'model': model.state_dict(),
            'scaler': scaler,
            'encoder': label_encoder,
            'config': config_parameters},
            trainedmodelpath)

