Skip to content

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

@creater-zq

Description

@creater-zq

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions