Torchvision ResNet Input Size

I printed modules in the ResNet and found why:

The AvgPool before the last FC is like this:
(avgpool): AvgPool2d (size=7, stride=7, padding=0, ceil_mode=False, count_include_pad=True)

Therefore as long as the input image size makes the AvgPool output tensors of size 1x2048x1x1, there is no problem. But if the input size is not 224x224, it is cropped by ResNet implicitly at AvgPool layer.

3 Likes