Hey guys, I am trying to load a trained CNN classifier that I saved so I can modify the linear layers, but I get a size mismatch error when performing a forward pass (train or eval, doesn’t matter). Here is the output:
Exception NameError: “global name ‘FileNotFoundError’ is not defined” in <bound method _DataLoaderIter.del of <torch.utils.data.dataloader._DataLoaderIter object at 0x7fcbc02c3350>> ignored
Traceback (most recent call last):
File “train_triplet_loss.py”, line 169, in 
outputs = F.softmax(old_model(images))
File “/home/zswartz/.local/lib/python2.7/site-packages/torch/nn/modules/module.py”, line 491, in call
result = self.forward(*input, **kwargs)
File “/home/zswartz/.local/lib/python2.7/site-packages/torch/nn/modules/container.py”, line 91, in forward
input = module(input)
File “/home/zswartz/.local/lib/python2.7/site-packages/torch/nn/modules/module.py”, line 491, in call
result = self.forward(*input, **kwargs)
File “/home/zswartz/.local/lib/python2.7/site-packages/torch/nn/modules/linear.py”, line 55, in forward
return F.linear(input, self.weight, self.bias)
File “/home/zswartz/.local/lib/python2.7/site-packages/torch/nn/functional.py”, line 994, in linear
output = input.matmul(weight.t())
RuntimeError: size mismatch, m1: [72 x 2], m2: [144 x 100] at /pytorch/aten/src/THC/generic/THCTensorMathBlas.cu:249
If I completely strip away the linear layers, and just leave the conv layers, there is no size mismatch error. Keep in mind, I am using the same exact data loader that I used to train the network in the first place. This isn’t a huge deal because I plan to strip away the linear layers regardless, but I would like to  verify that the frozen model performs as it was trained. I have a feeling that this may have something to do with the fact that I use “.view(-1, 144)” to flatten my final feature map in the forward method before the first linear layer, which is where this error is occurring.