‫The last foundational concept we need to understand before we start building our CNN model in the software,
‫it is that of a pooling layer.
‫And since you know how convolutional layers work, pooling layer is going to be easy to understand.
‫We use pulling layer in our network to reduce the computational load, memory usage and the number of
‫parameters to be estimated.
‫Just like in Convolutional layer each neuron in a pooling layer also has a small, rectangular, receptive
‫field.
‫We have to define the size of this rectangular, receptive field.
‫The stride, the padding type, just like before
‫However, pooling neurons have no weight.
‫All they do is aggregate the input using an aggregate function such as Max or mean in this image.
‫The layer on top is that of a pooling layer.
‫You can see that each neuron is looking at a two by two set of neurons on the lower layer.
‫The first neuron is looking at these four cells which have a red boundary.
‫Next is looking at these four, which are dotted blue boundary.
‫This means that the stride here is two.
‫By default, the stride in a pooling layer is same as the width or the deceptive field.
‫Now, if we use max function or max pooling, as it is called.
‫Only the maximum input value, out of the four values in this receptive field makes it to the next
‫Layer
‫The other three inputs are dropped.
‫For example, if these are the four output of these four cells, one, five, three, two, then out of
‫these four, five is the largest value.
‫So this neuron in the top layer will have five as output.
‫So it is very simple.
‫No weights, no filters to be trained.
‫Just find the maximum value out of the four values that it sees and it outputs that.
‫If you look at the gif at the bottom.
‫If this is the feature map at which are Max pulling layer is looking at.
‫For the first squared of four
‫Neurons.
‫The largest value is six.
‫So we enter six here in the first cell of the max pooling layer.
‫Similar to Max pooling, there is average pooling, in average pooling.
‫We find out the mean of the four values.
‫So if we are doing average pulling, it will be the average of these four values, six, six, four
‫and five.
‫So that averages five point two five.
‫In the next stride, we look at the next forcefield and we find out their max and the average value.
‫Those are stored in the next year on.
‫Now, also notice that since we are using a stride of 2 here.
‫The pooling layer has half the width and half the height of previously layer
‫You can now imagine how this will reduce the computations and memory usage.
‫Instead of pooling layer.
‫If we had the next convolutional lives straight away.
‫So that layer would have six into eight. Six as height and eight as width
‫So six into eight
‫Forty eight input neurons.
‫So each neuron in the next layer would have forty eight parameters to be trained.
‫But if we have this pooling layer on top.
‫Then each neuron gets only three into four.
‫That is 12 input neurons.
‫So only 12 parameters per neuron are to be trained.
‫So instead of 48, we get 12 parameters
‫To be trained. So the amount of computation goes down significantly.
‫So in this example, we saw that we can do both.
‫Max pooling and mean pulling, but commonly Max pooling works better than the alternative options
‫because it highlights the main features instead of averaging them out.
‫So in our model, most often we'll be using Max, pulling only.
‫That's it.
‫This is the concept behind Max pooling.
‫It is a trade off
‫We give away some extra information in the previous layer to reduce the computational load on our system.
‫I will highlight this impact on computation when we write the code.