I’m trying to apply senet for classification problem. as you can see in the image, last conv2d takes in 128 channels and outputs 2048 channels. so I made last linear layer (2048, 1383)
I only changed last 1000 to 1383 and the following error comes out.
RuntimeError: size mismatch, m1: [32 x 4096], m2: [2048 x 1383] at /pytorch/aten/src/THC/generic/THCTensorMathBlas.cu:266
It looks like your spatial size is not 1x1 after the last pooling layer, but apparently 2x1 or 1x2.
Could you check that by adding a print statement showing the shape of your activation before flattening it it your forward method?
I printed out the shape after the avg_pool layer and I got (batch size, 2048, 1, 1). Isn’t this correct?
if I make in_features 4096 it works fine, but it makes me uncomfortable…
I changed the following code and generated x = torch.randn(1, 3, 224, 224)
and got the following shape (1, 2048, 1, 1)
I do not see which part that I’m doing wrong