Missing key(s) in state_dict

 

Missing key(s) in state_dict

解决方法:

try:
    from collections import OrderedDict
    new_state_dict = OrderedDict()
    for k, v in state_dict.items():
        name = 'module.'+k  # add `module.`
        new_state_dict[name] = v
    # load params
    # model.load_state_dict(new_state_dict)
    self.net.load_state_dict(new_state_dict)
except Exception as e:
    print(e)

你可能感兴趣的:(torch)