Error(s) in loading state_dict for ResNetPlus: Missing key(s) in state_dict: "head.1.weight", "head.1.bias" #832
Unanswered
nehakulkarni15
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello,
I have pre-trained a network using ResNet50 and am now trying to finetune it on another dataset. However, when I try to load the model and fine tune it, I get the error below. It appears that the torch sizes are what they are supposed to be. Could somebody please guide me on how to fix this?
Best,
N
Here is the snippet of code I used to fine_tune:
new_splits = get_splits(yNew)
print(new_splits)
tfms = [None, TSClassification()]
batch_tfms = TSStandardize(by_sample=True)
dls3 = get_ts_dls(xNew, yNew, splits=new_splits, tfms=tfms, batch_tfms=batch_tfms, path='/directory')
learn3 = ts_learner(dls3, ResNetPlus, metrics=accuracy, cbs=[ShowGraph()])
learn3 = learn3.load('/directory/models/pretrained_model', device=device)
learn3.fine_tune(5)
And the following error:
RuntimeError: Error(s) in loading state_dict for ResNetPlus:
Missing key(s) in state_dict: "head.1.weight", "head.1.bias".
Unexpected key(s) in state_dict: "head.2.weight", "head.2.bias".
size mismatch for backbone.0.convblock1.0.weight: copying a param with shape torch.Size([96, 1, 7]) from checkpoint, the shape in current model is torch.Size([64, 1, 7]).
size mismatch for backbone.0.convblock1.1.weight: copying a param with shape torch.Size([96]) from checkpoint, the shape in current model is torch.Size([64]).
size mismatch for backbone.0.convblock1.1.bias: copying a param with shape torch.Size([96]) from checkpoint, the shape in current model is torch.Size([64]).
size mismatch for backbone.0.convblock1.1.running_mean: copying a param with shape torch.Size([96]) from checkpoint, the shape in current model is torch.Size([64]).
size mismatch for backbone.0.convblock1.1.running_var: copying a param with shape torch.Size([96]) from checkpoint, the shape in current model is torch.Size([64]).
size mismatch for backbone.0.convblock2.0.weight: copying a param with shape torch.Size([96, 96, 5]) from checkpoint, the shape in current model is torch.Size([64, 64, 5]).
size mismatch for backbone.0.convblock2.1.weight: copying a param with shape torch.Size([96]) from checkpoint, the shape in current model is torch.Size([64]).
size mismatch for backbone.0.convblock2.1.bias: copying a param with shape torch.Size([96]) from checkpoint, the shape in current model is torch.Size([64]).
size mismatch for backbone.0.convblock2.1.running_mean: copying a param with shape torch.Size([96]) from checkpoint, the shape in current model is torch.Size([64]).
size mismatch for backbone.0.convblock2.1.running_var: copying a param with shape torch.Size([96]) from checkpoint, the shape in current model is torch.Size([64]).
size mismatch for backbone.0.convblock3.0.weight: copying a param with shape torch.Size([96, 96, 3]) from checkpoint, the shape in current model is torch.Size([64, 64, 3]).
size mismatch for backbone.0.convblock3.1.weight: copying a param with shape torch.Size([96]) from checkpoint, the shape in current model is torch.Size([64]).
size mismatch for backbone.0.convblock3.1.bias: copying a param with shape torch.Size([96]) from checkpoint, the shape in current model is torch.Size([64]).
size mismatch for backbone.0.convblock3.1.running_mean: copying a param with shape torch.Size([96]) from checkpoint, the shape in current model is torch.Size([64]).
size mismatch for backbone.0.convblock3.1.running_var: copying a param with shape torch.Size([96]) from checkpoint, the shape in current model is torch.Size([64]).
size mismatch for backbone.0.shortcut.0.weight: copying a param with shape torch.Size([96, 1, 1]) from checkpoint, the shape in current model is torch.Size([64, 1, 1]).
size mismatch for backbone.0.shortcut.1.weight: copying a param with shape torch.Size([96]) from checkpoint, the shape in current model is torch.Size([64]).
size mismatch for backbone.0.shortcut.1.bias: copying a param with shape torch.Size([96]) from checkpoint, the shape in current model is torch.Size([64]).
size mismatch for backbone.0.shortcut.1.running_mean: copying a param with shape torch.Size([96]) from checkpoint, the shape in current model is torch.Size([64]).
size mismatch for backbone.0.shortcut.1.running_var: copying a param with shape torch.Size([96]) from checkpoint, the shape in current model is torch.Size([64]).
size mismatch for backbone.1.convblock1.0.weight: copying a param with shape torch.Size([192, 96, 7]) from checkpoint, the shape in current model is torch.Size([128, 64, 7]).
size mismatch for backbone.1.convblock1.1.weight: copying a param with shape torch.Size([192]) from checkpoint, the shape in current model is torch.Size([128]).
size mismatch for backbone.1.convblock1.1.bias: copying a param with shape torch.Size([192]) from checkpoint, the shape in current model is torch.Size([128]).
size mismatch for backbone.1.convblock1.1.running_mean: copying a param with shape torch.Size([192]) from checkpoint, the shape in current model is torch.Size([128]).
size mismatch for backbone.1.convblock1.1.running_var: copying a param with shape torch.Size([192]) from checkpoint, the shape in current model is torch.Size([128]).
size mismatch for backbone.1.convblock2.0.weight: copying a param with shape torch.Size([192, 192, 5]) from checkpoint, the shape in current model is torch.Size([128, 128, 5]).
size mismatch for backbone.1.convblock2.1.weight: copying a param with shape torch.Size([192]) from checkpoint, the shape in current model is torch.Size([128]).
size mismatch for backbone.1.convblock2.1.bias: copying a param with shape torch.Size([192]) from checkpoint, the shape in current model is torch.Size([128]).
size mismatch for backbone.1.convblock2.1.running_mean: copying a param with shape torch.Size([192]) from checkpoint, the shape in current model is torch.Size([128]).
size mismatch for backbone.1.convblock2.1.running_var: copying a param with shape torch.Size([192]) from checkpoint, the shape in current model is torch.Size([128]).
size mismatch for backbone.1.convblock3.0.weight: copying a param with shape torch.Size([192, 192, 3]) from checkpoint, the shape in current model is torch.Size([128, 128, 3]).
size mismatch for backbone.1.convblock3.1.weight: copying a param with shape torch.Size([192]) from checkpoint, the shape in current model is torch.Size([128]).
size mismatch for backbone.1.convblock3.1.bias: copying a param with shape torch.Size([192]) from checkpoint, the shape in current model is torch.Size([128]).
size mismatch for backbone.1.convblock3.1.running_mean: copying a param with shape torch.Size([192]) from checkpoint, the shape in current model is torch.Size([128]).
size mismatch for backbone.1.convblock3.1.running_var: copying a param with shape torch.Size([192]) from checkpoint, the shape in current model is torch.Size([128]).
size mismatch for backbone.1.shortcut.0.weight: copying a param with shape torch.Size([192, 96, 1]) from checkpoint, the shape in current model is torch.Size([128, 64, 1]).
size mismatch for backbone.1.shortcut.1.weight: copying a param with shape torch.Size([192]) from checkpoint, the shape in current model is torch.Size([128]).
size mismatch for backbone.1.shortcut.1.bias: copying a param with shape torch.Size([192]) from checkpoint, the shape in current model is torch.Size([128]).
size mismatch for backbone.1.shortcut.1.running_mean: copying a param with shape torch.Size([192]) from checkpoint, the shape in current model is torch.Size([128]).
size mismatch for backbone.1.shortcut.1.running_var: copying a param with shape torch.Size([192]) from checkpoint, the shape in current model is torch.Size([128]).
size mismatch for backbone.2.convblock1.0.weight: copying a param with shape torch.Size([192, 192, 7]) from checkpoint, the shape in current model is torch.Size([128, 128, 7]).
size mismatch for backbone.2.convblock1.1.weight: copying a param with shape torch.Size([192]) from checkpoint, the shape in current model is torch.Size([128]).
size mismatch for backbone.2.convblock1.1.bias: copying a param with shape torch.Size([192]) from checkpoint, the shape in current model is torch.Size([128]).
size mismatch for backbone.2.convblock1.1.running_mean: copying a param with shape torch.Size([192]) from checkpoint, the shape in current model is torch.Size([128]).
size mismatch for backbone.2.convblock1.1.running_var: copying a param with shape torch.Size([192]) from checkpoint, the shape in current model is torch.Size([128]).
size mismatch for backbone.2.convblock2.0.weight: copying a param with shape torch.Size([192, 192, 5]) from checkpoint, the shape in current model is torch.Size([128, 128, 5]).
size mismatch for backbone.2.convblock2.1.weight: copying a param with shape torch.Size([192]) from checkpoint, the shape in current model is torch.Size([128]).
size mismatch for backbone.2.convblock2.1.bias: copying a param with shape torch.Size([192]) from checkpoint, the shape in current model is torch.Size([128]).
size mismatch for backbone.2.convblock2.1.running_mean: copying a param with shape torch.Size([192]) from checkpoint, the shape in current model is torch.Size([128]).
size mismatch for backbone.2.convblock2.1.running_var: copying a param with shape torch.Size([192]) from checkpoint, the shape in current model is torch.Size([128]).
size mismatch for backbone.2.convblock3.0.weight: copying a param with shape torch.Size([192, 192, 3]) from checkpoint, the shape in current model is torch.Size([128, 128, 3]).
size mismatch for backbone.2.convblock3.1.weight: copying a param with shape torch.Size([192]) from checkpoint, the shape in current model is torch.Size([128]).
size mismatch for backbone.2.convblock3.1.bias: copying a param with shape torch.Size([192]) from checkpoint, the shape in current model is torch.Size([128]).
size mismatch for backbone.2.convblock3.1.running_mean: copying a param with shape torch.Size([192]) from checkpoint, the shape in current model is torch.Size([128]).
size mismatch for backbone.2.convblock3.1.running_var: copying a param with shape torch.Size([192]) from checkpoint, the shape in current model is torch.Size([128]).
size mismatch for backbone.2.shortcut.weight: copying a param with shape torch.Size([192]) from checkpoint, the shape in current model is torch.Size([128]).
size mismatch for backbone.2.shortcut.bias: copying a param with shape torch.Size([192]) from checkpoint, the shape in current model is torch.Size([128]).
size mismatch for backbone.2.shortcut.running_mean: copying a param with shape torch.Size([192]) from checkpoint, the shape in current model is torch.Size([128]).
size mismatch for backbone.2.shortcut.running_var: copying a param with shape torch.Size([192]) from checkpoint, the shape in current model is torch.Size([128]).
Beta Was this translation helpful? Give feedback.
All reactions