The recommended way to serialize a model would be to store its state_dict as described here 12. Based on the error you are seeing it seems you’ve stored the entire model via torch.save(model, path). If that’s the case, you would have to make sure the code structure while loading the model is equal to the one used during the saving.