Pooling layers

In addition to convolutional layers, convolutional neural networks often use another type of layer called a pooling layer. Pooling layers are used to reduce the dimensionality of a convolutional network as layers of convolutions are added, which reduces overfitting. They have the added benefit of making the feature detectors somewhat more robust.

Pooling layers divide a matrix into non-overlapping sections, and then typically take the maximum value (in the case of max pooling) in each region. Alternatively, an average can be employed; however, it is rarely used at this time. The following figure illustrates this technique:

Pooling layers are quite easy to implement in Keras, as we'd expect. The following code can be used for pooling the layers:

from keras.layers import MaxPooling2D
pool1 = MaxPooling2D(pool_size=(2, 2), name="pool_1")

Here, we're defining the pooling window as 2 x 2.

While we previously haven't discussed padding, it's common to, in some architectures, pad the input of either a convolutional layer or pooling layer with 0s such that the output dimension is equal to the input. The default in both convolutional and pooling layers in Keras is valid padding, which means no padding by convention. The parameter padding="same" will apply padding if you want that.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.137.167.195