pytorch错误解决: Missing key(s) in state_dict: Unexpected key(s) in state_dict:

pytorch错误解决:
Missing key(s) in state_dict:

Unexpected key(s) in state_dict:

解决:

在模型参数被加载到模型前加下面的语句:

model = nn.DataParallel(model)

#cudnn.benchmark = True

model.load_state_dict(pth,False)
且在加载模型中添加一个False

你可能感兴趣的:(pytorch错误解决: Missing key(s) in state_dict: Unexpected key(s) in state_dict:)