I am trying to use a pretrained ResNet model but I get this error:
RuntimeError: size mismatch, m1: [30 x 2048], m2: [9216 x 1024] at /pytorch/aten/src/THC/generic/THCTensorMathBlas.cu:283
model.fc = nn.Sequential(nn.Linear(9216,1024), nn.ReLU(),nn.Dropout(0.4),nn.Linear(1024,10))
Full Notebook can be found here: https://colab.research.google.com/drive/1k40NNulSIS6ANagopSPBH4Xty_Cw39qC#scrollTo=9J6VCm2y8tXn
Please I would really appreciate a bit of help with this issue since I am a new practitioner. Thanks in advanced.
It looks like you already corrected the number of input features to
Yes Thanks for your help! However, I am still getting an error that seems to be in the test loader and cannot find where…if you have a clue I will appreciate it a lot.
Which error are you getting now?
I got this: RuntimeError: Input type (torch.FloatTensor) and weight type (torch.cuda.FloatTensor) should be the same
In the Google Colab link of my first post this message can be seen at the very end of the notebook.
Thanks a million for your kindness.
This error points to a device mismatch between your input tensor and the model parameters.
You should push
X_test to the device (same as with the training data) via:
X_test = X_test.cuda().
I did see your colab code.
You have used
train_loader instead of
valid_loader for testing the performance. In the validation you’ll have to move the
X_test, y_test to CUDA to solve the issue.
Thanks a million for your kindness!
Thanks a million for your help @SANTOSH_S! It is important for people like me who are not really experienced to receive feedback from experts like you and @ptrblck. I really appreciate it.