Connect your moderator Slack workspace to receive post notifications:
Sign in with Slack

Input size ConvNets

Hi,

I have a (maybe basic) question regarding the input size for CNN based networks.
Let's say we want to train a model for image classification, after searching on the net it appears that you cannot test your model with pictures that doesn't have the same size as the images we used to train with, this is due to the last fully connected layers that have a fixed size number of nodes.
On the other hand, if we have a Fully Convolutional Network (for image segmentation for example) apparently it is possible to test with images that have different sizes than the train images. Why is that ?

Thank you !

you cannot test your model with pictures that doesn't have the same size as the images we used to train with, this is due to the last fully connected layers that have a fixed size number of nodes.

Correct. The fully connected layers are the reason. A possible way to allow for differently sized input for a classification CNN is to use "global pooling". This reduces any channel, regardless of its size, to a single value. This allows then to use a fixed-size fully connected layer at the end.
See also: https://medium.com/mindboard/image-classification-with-variable-input-resolution-in-keras-cbfbe576126f

if we have a Fully Convolutional Network (for image segmentation for example) apparently it is possible to test with images that have different sizes than the train images. Why is that_?

Because in that case there is no (limiting) fully connected layer. In image segmentation, for each pixel, a class probability will be learned. This in contrast to image (full sample) classification, where all the features of a sample are aggregated using a fully connected layer, but depending on the input image size there are more or less features.
See also: https://ai.stackexchange.com/questions/6274/how-can-i-deal-with-images-of-variable-dimensions-when-doing-image-segmentation

Thank you very much for your precise reply !

Page 1 of 1

Add comment

Post as Anonymous Dont send out notification