错误“load_state_dict self.__class__.__name__, "\n\t".join(error_msgs))) RuntimeError: Error(s) in

错误“load_state_dict self.class.name, “\n\t”.join(error_msgs))) RuntimeError: Error(s) in loading state_dict for ResNeXt:”

导入.pth文件错误如下:

load_state_dict
    self.__class__.__name__, "\n\t".join(error_msgs)))

RuntimeError: Error(s) in loading state_dict for ResNeXt:

代码如下:

aa=torch.load("resnext-101-kinetics-hmdb51_split1.pth",map_location='cpu')
model = resnext.resnet101(
                num_classes=101,
                shortcut_type='B',
                cardinality=32,
                sample_size=112,
                sample_duration=16)

model.load_state_dict(aa["state_dict"])

修改:

model.load_state_dict(checkpoint['state_dict'], strict=False)

你可能感兴趣的:(error,错误,RuntimeError:,Error(s),in,loading,s,.pth,load_state_dict)