Average Pooling Layer
Average pooling is a downsampling operation used in CNNs that reduces spatial dimensions by computing the **mean value** within each non-overlapping window of a given size. Unlike max pooling which selects the strongest activation, average pooling captures the overall presence of features in a region.
Formula:
output[i, j] = mean(input[i*s : i*s + p, j*s : j*s + p])
Where:
s = stride (equal to pool_size for non-overlapping)
p = pool_size
Output dimensions:
output_height = input_height / pool_size
output_width = input_width / pool_size
Example:
Input: [[1, 2, 3, 4], pool_size = 2
[5, 6, 7, 8],
[9, 10, 11, 12],
[13, 14, 15, 16]]
Window 1: [[1,2],[5,6]] -> mean = 3.5
Window 2: [[3,4],[7,8]] -> mean = 5.5
Window 3: [[9,10],[13,14]] -> mean = 11.5
Window 4: [[11,12],[15,16]] -> mean = 13.5
Output: [[3.5, 5.5],
[11.5, 13.5]]
Average pooling smooths out the feature map by averaging activations within each pool region. It is often preferred over max pooling in tasks where the overall distribution of features matters rather than just the strongest signal.
Constraints:
Test Cases
[[1,2],[3,4]] 2[[2.5]][[1,2,3],[4,5,6],[7,8,9]] 2[[3.0,4.0],[7.0,8.0]]