can the input image shape be 28x28 for training or testing renet18? I read that input image shape should be multiples of 32x32 but is that really required or does present resnet18 take care by itself?
I trained the resnet18 on MNIST data set their shape is 28x28. But i did not face any problem while training or testing, even though the shape is not a multiple of 32x32. Is this okay or do i need to train the model again by resizing the image to 224x224?
If it’s not a multiple of 32, you will lose some values in the intermediate layers due to having odd sizes of tensors. That may or may not be a problem for the problem you are solving, but in general, it would be better to resample the images to at least 32x32 if you wish to use unmodified resnet18 architecture.
thanks for the answer. So there is no adaptive pooling layer in resnet which makes image shape to a multiple of 32x32 as in fast ai (https://forums.fast.ai/t/why-mnist-works-with-resnet-without-throwing-error/57855)?
The adaptive pooling only happens right before the classifier part of the network and just serves to average the size down to a single feature vector. Issue with something like 28x28 is that since there are several layers with stride=2
, you will be disproportionally losing values out of the right side of the image. Again, it probably won’t be an issue for MNIST, because the image is mostly uniform background near the sides anyway.
It is clear now, thanks!