pytorch collections.OrderedDict' 对象没有属性 'to'

时间:2021-03-17 09:31:12

标签: pytorch

这是我的主要代码,但我不知道如何解决问题?

c.getImageData

1 个答案:

答案 0 :(得分:3)

您正在加载检查点作为状态字典,它不是 nn.module 对象。

checkpoint = './checkpoints/fcn_model_5.pth'

model = your_model() # a torch.nn.Module object
model.load_state_dict(torch.load(checkpoint ))
model = model.to(device)