I’m working on cifar10 dataset and I have a problem.
RuntimeError: mat1 and mat2 shapes cannot be multiplied (64x1000 and 2048x1000)
I can’t fix this error. The paper says to use pretrained resnet-50. What should I do?
I’m working on cifar10 dataset and I have a problem.
RuntimeError: mat1 and mat2 shapes cannot be multiplied (64x1000 and 2048x1000)
I can’t fix this error. The paper says to use pretrained resnet-50. What should I do?
All resnets implemented in torchvision
were trained on ImageNet
with 1000 classes and thus output logits in the shape [batch_size, nb_classes=1000]
. If you want to replace the last linear layer, access it via model.fc
and replace it with your new linear layer. Otherwise, if you want to really use these logits directly, set in_features=1000
in your linear layer, but note it’s not the common use case.