I have trained my model and now want to test it but I was getting this error while testing
AttributeError: 'OrderedDict' object has no attribute 'cuda'
The error comes after this:
model = torch.load(snapshot_path) model.cuda()
Is there any mistake in my training that it is not able to find the cuda parameter, since I had done the training on GPU.
How do you save your model?
if you saved the state dict, you have to load the model via
load_state_dict. Either read the documentation or look at our examples.
Have you found the solution for this issue? What would it be ya ?
Really need to know this
@smth’s answer is the solution to this.
model.load_state_dict(torch.load(PATH)) and for more details refer to the documentation (https://pytorch.org/tutorials/beginner/saving_loading_models.html)