Weight assignment issue

I am trying to assign pre-trained weights to my vgg-face model using the following code:-

netClassifier = Vgg_face()  
weight_vggFace = torch.load(weights_path)  

But im facing the following error, for which I could not find a proper solution. The error is as follows:-

While copying the parameter named "fc8.weight", whose dimensions in the model are torch.Size([2622, 4096, 1, 1]) and whose dimensions in the checkpoint are torch.Size([2622, 4096]).

Could someone kindly guide me on how to go about solving it.

May I ask how did you define your “fc8”? If it’s just torch.nn.Linear(2622, 4096) then there’s no way your weight would have 4 dimensions.

1 Like

You are right!! I just copy pasted the 1st line of code and changed only the filter sizes, strides, and paddings. Just skipped out of my mind!.
Thank you very very much for pointing this out.