The merge operation includes applying a two-dimensional filter on each channel of the feature map and summing the elements that lie in the area covered by the filter.
For a feature map with dimensions n h xn w xn c , the dimensions of the output received after the pool, are equal
(n h - f + 1) / sx (n w - f + 1) / sx n c
- & gt; n h - height of feature map - & gt; n w - width of feature map - & gt; n c - number of channels in the feature map - & gt; f - size of filter - & gt; s - stride length
The general architecture of the CNN model is to have multiple layers of convolution and join together one after the other.
Maximum pooling — it is a merge operation that selects the largest element from the area of the feature map that is covered by the filter. Thus, the output after the maximum pool layer will be the featuremap containing the most visible features of the previous featuremap.
This can be achieved with the MaxPooling2D layer in keras as follows:
Code # 1: Executing the maximum pool using keras b>
[[9. 7.] [8. 6.]]
Medium Merge calculates the average of the items present in the filtered area of the feature map. So while the max pool gives the most prominent feature in a particular feature map patch, the average pool gives the average of the features present in the patch.
Code # 2: Executing Medium Pool Using Keras
[[4.25 4.25] [4.25 3.5]]
Global pooling converts each channel in the feature map to a single value. Thus, the sitemap n h xn w xn c is reduced to the sitemap 1 x 1 xn c . This is equivalent to using the dimension filter n h xn w, i.e. measurements of the object map.
Alternatively, it can be either the Global Max Pool or the Global Medium Pool.
Code # 3: Executing a Global Pool Using Keras