问题加载模型;火炬

时间:2020-10-20 10:24:33

标签: pytorch

我正在尝试加载保存了以下内容的模型,这给了我这个错误:

import torch

model = torch.load('./grunet.pkl')
model.eval()

这是错误:

  Traceback (most recent call last):
  File ".\eval.py", line 4, in <module>
    model.eval()
  AttributeError: 'NoneType' object has no attribute 'eval'

请帮助!

1 个答案:

答案 0 :(得分:0)

您缺少一步:

model = YourModelClass()
model.load_state_dict(torch.load("./grunet.pkl"))
model.eval()

# do something with the model