I am trying to do face detection using a resnet50 model and am getting the following error:
RuntimeError: The size of tensor a (1000) must match the size of tensor b (64) at non-singleton dimension 1
My input consists of 128x128 px images with 3 channels and a batch size of 64.
I can see that my resnet50 model has out_features=1000 set, but I am not quite sure what the right steps are to fix this problem.
I tried doing a matrix multiplication in my loss and metric functions to decrease the tensor size from 1000 to 64, but if I do that I get another error that the tensor size must match 16 instead of 64. So this doesn’t seem to be the right solution.
Also learn.lr_find() isn’t completing successfully and I don’t know if F.mse_loss is the right function here, anyway I first want to get it working with a batch size of 64 before I tackle the next problem.
You might want to use create_cnn to create a learner instead of directly instantiating a learner. I don’t think you need to explicitly specify a loss function as well. I think fastai library interprets a classification from a regression problem and automatically applies the right loss function.