pytorch加载预训练模型报错-解决

pytorch加载预训练模型时报错:

File "train_refinedet.py", line 115, in train
    refinedet_net.vgg.load_state_dict(vgg_weights)
  File "/home/em/anaconda3/lib/python3.5/site-packages/torch/nn/modules/module.py", line 769, in load_state_dict
    self.__class__.__name__, "\n\t".join(error_msgs)))
RuntimeError: Error(s) in loading state_dict for ModuleList:
    Missing key(s) in state_dict: "0.bias", "0.

解决方法:

refinedet_net.vgg.load_state_dict(vgg_weights)
修改为:
refinedet_net.vgg.load_state_dict(vgg_weights,False)

 

你可能感兴趣的:(python,pytorch)