1-channel Resnet50 not working with different input sizes

This is the problem. Original resnet uses adaptive_avg_pool2d(out, (1, 1)) in its last layer before connecting it to linear layer. So, if you change this line to
out = F.adaptive_avg_pool2d(out, (1, 1)),
your model will work just fine. This layer forces output to be in shape of output_size=(1, 1).

Here is a post about how it works:

Here is the link to source code of this line:

bests

1 Like