Hi all!
I got an error like this
Traceback (most recent call last):
File “DeepCoral.py”, line 115, in 
model = load_pretrain(model)
File “DeepCoral.py”, line 48, in load_pretrain
model_dict[k] = pretrained_dict[k[k.find(".") + 1:]]
KeyError: ‘bn1.num_batches_tracked’
when I tried to load a pre-trained ResNet model from pytorch “https://download.pytorch.org/models/resnet50-19c8e357.pth 27”
My loading function for the pre-trained model is:
def load_pretrain(model):
url = ‘https://download.pytorch.org/models/resnet50-19c8e357.pth 27’
pretrained_dict = model_zoo.load_url(url)
model_dict = model.state_dict()
for k, v in model_dict.items():
if not “cls_fc” in k:
model_dict[k] = pretrained_dict[k[k.find(".") + 1:]]
model.load_state_dict(model_dict)
return model
Could anyone please to help me?