PytorchInsight icon indicating copy to clipboard operation
PytorchInsight copied to clipboard

"sk_resnet101.pth.tar" pre-training model could not be loaded, in pytorch

Open creater-zq opened this issue 4 years ago • 0 comments

my code:

   def get_se_resnet101(path_state_dict, device, vis_model=False):
        model = resnet_se.se_resnet101()
        if path_state_dict:
              pretrained_state_dict = torch.load(path_state_dict, map_location=torch.device('cpu'))
              model.load_state_dict(pretrained_state_dict, )

error:

raise RuntimeError('Error(s) in loading state_dict for {}:\n\t{}'.format(
RuntimeError: Error(s) in loading state_dict for ResNet:
    Missing key(s) in state_dict: "conv1.weight", "bn1.weight", "bn1.bias", "bn1.running_mean", "bn1.running_var", ...... 
    Unexpected key(s) in state_dict: "epoch", "state_dict", "acc", "best_acc", "optimizer"

How to solve it? thanks

creater-zq avatar Feb 15 '21 16:02 creater-zq