Pooling
Pooling is a technique used in convolutional neural networks (CNNs) to reduce the dimensionality of the input while retaining important features. There are several types of pooling operations, such as max pooling, average pooling, and sum pooling. Max pooling is the most commonly used type of pooling in CNNs.
In a CNN, the pooling layer is typically inserted between the convolutional layer and the fully connected layer. The purpose of the pooling layer is to reduce the spatial size of the input, which helps to reduce the number of parameters and computational complexity of the model. It also helps to reduce overfitting by reducing the sensitivity of the model to small translations in the input.
Max pooling
Max pooling works by dividing the input into a set of non-overlapping regions and taking the maximum value from each region. For example, if the input has a size of [5, 5] and the pooling window has a size of [3, 3], the max pooling operation will take the maximum value from each 3×3 window of the input, resulting in an output with a size of [2, 2].
What is the difference between ‘SAME’ and ‘VALID’ padding in tf.nn.max_pool of tensorflow?
Padding is a technique used in convolutional neural networks (CNNs) to preserve the spatial dimensions of the input data and prevent the loss of information at the edges of the image. It involves adding additional rows and columns of pixels around the edges of the input data. There are several different ways to apply padding in Python, depending on the type of padding being used.
Let’s an image of dimension is having filtered with dimension kernel with stride then the output shape will be:
Then the output shape will be
Where, C = number of filtered channel.
For example the image of shape is filtered with kernel with stride length =2 then the output shape of the image will be.
So, the image shrinks when the convolution is performed.
And the corner and edge pixels do have not equal participation. as we can see from the figure below.
To resolve this we add extra layers of zeros to our image, which is known as the same padding.