Pooling operation
Pooling or subsampling is a simple operation of input size decreasing (Figure 9.2). If you have a black and white image, and you want to decrease its size, you can do it in the following way: chose a sliding window of size n × m and stride s. Go through the image, applying sliding window and shifting on the s pixels every time you want to move your window. At each position calculate an average (for average pooling) or maximum (for max pooling) and record this value into the destination matrix. Now, there are two common ways to handle borders of the image:
Figure 9.2. Pooling operation. Grey window in the source image corresponds to the grey cell in the destination image
The pooling is used in the CNNs to reduce the size of the data, as it travels down the network.