2
$\begingroup$

On this article, it says that:

The UNET was developed by Olaf Ronneberger et al. for Bio Medical Image Segmentation. The architecture contains two paths. First path is the contraction path (also called as the encoder) which is used to capture the context in the image. The encoder is just a traditional stack of convolutional and max pooling layers. The second path is the symmetric expanding path (also called as the decoder) which is used to enable precise localization using transposed convolutions. Thus it is an end-to-end fully convolutional network (FCN), i.e. it only contains Convolutional layers and does not contain any Dense layer because of which it can accept image of any size.

So what I don't understand is how an FCN can accept images of any size, while an ordinary object detector such as YOLO with a dense layer at the very end cannot accept images of any size. Can someone please explain as to why this is.

$\endgroup$
  • $\begingroup$ Because it don't have dense layers obviously. Convolutional layer work for any input size (more then kernel size) $\endgroup$ – mirror2image Jun 27 at 9:30
4
$\begingroup$

The reason is that when using a Convolutional layer, you select the size of the filter kernels, which are independent of the image/layer input size (provided that images smaller than the kernels are padded appropriately).

When using a Dense layer, you specify the size of the layer itself and the resulting weight matrix is a function of both the size of the Dense layer and the upstream layer. This is because each neuron in the upstream layer makes a connection to each neuron in the Dense layer. So if you have 50 neurons in the upstream layer and 20 neurons in the Dense layer, then the weight matrix has 50x20=1000 values. Those weights are what get determined during the training phase and so those layer sizes are fixed.

Now, the output of a CNN layer is a number of images/tensors (specified by the number of filters chosen) whose size is determined by the kernel size and any padding option chosen. If those feed into a Dense layer then that fixes the the size that those images can be (because of the reason given in the previous paragraph). On the other hand, if no Dense layer is used in the whole network then the input to the first CNN layer can be any size because the weights are just the individual parameters of the filter kernels, and the filter kernels remain the same size regardless of the input tensor size.

$\endgroup$
  • $\begingroup$ can you elaborate on the logic of the dense layer relating to the upstream layer? $\endgroup$ – Sharan Duggirala Jun 27 at 10:10
  • 1
    $\begingroup$ @SharanDuggirala Done. $\endgroup$ – DrMcCleod Jun 27 at 12:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.