Hi,
I’m doing a transfer learning to a pretrained network on  cifar 10, but I get a very odd runtime error, even though it seems like there’s no problem with input and output sizes.
Basically all I did was just changing the network and optimizer section from a working code. It’s very odd considering all I did was relying on code from Udacity. PyTorch’s tutorial shows a very similar way to do it, tried that too and got the same error.
That’s the section, very simple:
model = models.densenet121(pretrained=True)
for param in model.parameters():
    param.requires_grad = False    

model.classifier = nn.Sequential(nn.Linear(1024, 256),
                                  nn.ReLU(),
                                  nn.Dropout(0.2),
                                  nn.Linear(256, 10),
                                  nn.LogSoftmax(dim=1)) 

if torch.cuda.is_available():
    model.cuda()

criterion = nn.NLLLoss()
optimizer = optim.Adam(model.classifier.parameters(), lr=0.01)

For ease, that’s the classifying layer from dense121:
(classifier): Linear(in_features=1024, out_features=1000, bias=True).
All I did  was just replacing (1024,1000) with something else. Any idea why I get the following error?
(python 3.6, pytorch 0.4.0)
RuntimeError: Given input size: (1024x1x1). Calculated output size: (1024x-5x-5). Output size is too small at /opt/conda/conda-bld/pytorch_1525909934016/work/aten/src/THCUNN/generic/SpatialAveragePooling.cu:63