6
$\begingroup$

I am reading Francois Chollet's Deep learning with Python, and I came across a section about max-pooling that's really giving me trouble.

I am unable to copy-paste the content, so I've included screenshots of the paragraph that's troubling me.

I simply don't understand what he means when he talks about "What's wrong with this setup?" (towards the end).

How does removing the max-pooling layers "reduce" the amount of the initial image that we're looking at? What are the benefits of using max-pooling in convolutional neural networks, as opposed to just using convolution layers?

enter image description here

enter image description here

$\endgroup$
  • $\begingroup$ I think the "What's wrong with this setup" paragraph is trying to convey this: Lets say you have an extreme scenario of a 10^5 x 10^5 sized input image of a car, the conv net sees this image as slices of size 7x7 using this example, and in such a massive image, a slice like that hardly show anything. By maxpooling, you essentially "collect" a group of these slices, so the next time the conv net sees the image, it sees a larger window and can therefor identify over-arching features $\endgroup$ – Recessive Jul 26 at 2:33
  • $\begingroup$ @Recessive thank you for your comment. Where do you think the 7 x 7 came from though? Like why did he mention 7 x 7 specifically? (how did he get that number?) $\endgroup$ – user10796158 Jul 26 at 16:17
  • $\begingroup$ Essentially no proven benefits. Max pooling is not used in latest models any more. $\endgroup$ – mirror2image Jul 26 at 18:10
  • $\begingroup$ @user10796158 He's referring to the size of the filter for that particular conv layer, which is 7x7. You could increase the size of the filter to observe more of the image (say, 20x20 slices) and I don't believe there's actually anything wrong with that (aside from a large amount of computations). However, in spite of this, deepmind has found (arxiv.org/pdf/1804.04438.pdf) that the "what's wrong with this" is only true at initialisation, so it seems that regardless of maxpooling layers, the network will learn stability. $\endgroup$ – Recessive Jul 27 at 0:20
  • 1
    $\begingroup$ stats.stackexchange.com/questions/288261/… might be helpful $\endgroup$ – DuttaA Jul 27 at 9:37
1
$\begingroup$

MaxPooling pools together information. Imagine you have 2 convolutional layers $(F_1, F_2)$ respectively, each with a 3x3 kernel and a stride of $1$. Also, imagine your input is $I$ is of shape $(w,h)$. Let's call a max-pooling layer $M$ is of size $(2,2)$.

Note: I'm ignoring channels because, for these purposes, it's not necessary and can be extended to any amount of them.

Now you have two cases:

  1. $O_1 = F_2 \circ F_1 \circ I$
  2. $O_2 = F_2 \circ M \circ F_1 \circ I$

In these cases, $shape(O_1)=(w-4, h-4)$ and $shape(O_2)=\left(\frac{w-2}{2}-2, \frac{h-2}{2}-2 \right)$. If we plug in dummy values, like $w,h = 64,64$, we get the shapes become $(60,60)$ and $(29,29)$ respectively. As you can tell, these are very different!

Now, there is more of a difference than just the size of the outputs, each neuron holds a pooling of more information. Let's do it out:

  1. Each output neuron of $F_1 \circ I$ has information from a $(3,3)$ receptive field.

  2. Each output neuron then of $F_2 \circ F_1 \circ I$ has information from a $(3,3)$ receptive field of $F_1 \circ I$, which, if we eliminate reused nodes, is a $(5,5)$ receptive field from the initial $I$.

  3. Each output neuron then of $M \circ F_1 \circ I$ has information from a $(2,2)$ receptive field of $F_1 \circ I$, which, if we eliminate reused nodes, is a $(4,4)$ receptive field from the initial $I$.

  4. Each output neuron then of $F_2 \circ M \circ F_1 \circ I$ has information from a $(4,4)$ receptive field of $M \circ F_1 \circ I$, which, if we eliminate reused nodes, is a $(8,8)$ receptive field from the initial $I$.

So, let us discuss these: Using max-pooling reduces the feature space heavily by throwing out a lot of nodes whose features aren't as indicative (makes training models more tractable) along with it does extend the receptive field with no additional parameters.

$\endgroup$
  • $\begingroup$ @mshlis thank you for your answer. Do you mind elaborating on points 2,3, and 4? Specifically, how did you get the numbers (4,4) (5,5) and (6,6)? $\endgroup$ – user10796158 Jul 26 at 16:28
  • $\begingroup$ @user10796158 the convolution in point two's case is a 3x3 grid of nodes that touches local 3x3 grids of the layer even before that. To convince yourself draw it out and you get a grid thats 5x5 of the original. For the third point it works the same way just with a 2x2 and for the fourth point i forgot to include the stride of the maxpool, so its actually 8x8 $\endgroup$ – mshlis Jul 27 at 0:06

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.