‘collections.OrderedDict’ object has no attribute ‘to’

 

I have trained my model on GPU but I was getting this error while training
AttributeError:‘collections.OrderedDict’ object has no attribute ‘to’ ,
the code comes after this
my_resnet18 =torch.load(’…/resnet18model/best_model.pth’)
my_resnet18.fc =torch.nn.Sequential(nn.Linear(512, 16),nn.Tanh())
my_resnet18 = my_resnet18.to(device)
Is there anything wrong with this?
my pytorch version is 1.0.0

https://discuss.pytorch.org/t/collections-ordereddict-object-has-no-attribute-to/35520

 

 

 

 

 

 

 

 

 

 

 

 

你可能感兴趣的:(PyTorch)