I am currently reading the paper proposed by LeCun et al. for handwritten zip code recognition. There is this figure below visualizing the CNN architecture. But I do not really understand how the connection between Layer H1 and input layer makes sense. If there are 12 kernels with size 5x5, shouldn't the layer H1 be 12x144? Or is there any downsampling taking place here too?

CNN Architecture by LeCun et al.


Yes, the spatial dimensions (height and width) are reduced: the input is 16x16, H1 is 8x8 and H2 is 4x4.

Also see the first paragraph in the architecture section: enter image description here Source

In modern terms you would say that they use a stride of 2. Which reduces the spatial dimensions accordingly.

EDIT (based on your comment)

The formula for the spatial output dimension $O$ of a (square shaped) convolutional layer is the following:

$$O = \frac{I - K + 2P}S + 1$$ with $I$ being the input size, $K$ being the kernel size, $P$ the padding and $S$ the stride. Now you might think that in your example $O = \frac{16 - 5 + 2*2}2 + 1 = 8.5$ (assuming $P=2$)

But take a closer look at how it actually plays out when the 5x5 kernel of layer H1 scans the 16x16 input image with a stride of 2: enter image description here

As you can see from the light grey area the required and effective padding is actually not 2 on all sides. Instead for the width or height respectively it is 2 on one side and 1 on the other side, i.e. on average $(2+1)/2=1.5$.

And if you plug that into the equation to calculate the output size it gives: $O = \frac{16 - 5 + 2*1.5}2 + 1 = 8$. Accordingly the convolutional layer H1 will have spatial dimensions of 8x8.

  • $\begingroup$ Hi thanks for the reply! But the formula for output size calculation is: O=(input_size - filter_size)/stride + 1, right? in this case, the equation would be (16-5)/2 + 1 = 6,5, and not 8 :/ $\endgroup$ – user77241 Jan 2 '20 at 12:55
  • $\begingroup$ @EnyangWang That is the usual headache with this formula (tho you entirely skipped the padding). I have added an explanation. Hope it helps. $\endgroup$ – Sammy Jan 2 '20 at 14:40
  • $\begingroup$ hi, thanks for the further explanation! it seems to make sense, i just didnt read in the paper that they had applied padding, that is why i took out the padding from the equation :) thanks a lot, much appreciated! :) $\endgroup$ – user77241 Jan 5 '20 at 22:41

Your Answer

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