Max pooling is a downsampling operation commonly used in convolutional neural networks. It reduces the spatial dimensions of a feature map by selecting the maximum value within non-overlapping rectangular regions (pools). This helps reduce computation, extract dominant features, and provide a degree of spatial invariance.
Given a 2D matrix and a pool size, apply max pooling with non-overlapping windows (stride equal to pool size).
Return the pooled two-dimensional list.
Input: X = [[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12], [13, 14, 15, 16]], pool_size = 2
Output: [[6, 8], [14, 16]]
Explanation: Each non-overlapping 2 by 2 block contributes its maximum.
Input: X = [[1, 2, 3, 4, 5, 6], [7, 8, 9, 10, 11, 12], [13, 14, 15, 16, 17, 18], [19, 20, 21, 22, 23, 24], [25, 26, 27, 28, 29, 30], [31, 32, 33, 34, 35, 36]], pool_size = 3
Output: [[15, 18], [33, 36]]
Use integer division to count complete pooling windows along each dimension.
Initialize each maximum from the window’s top-left value, then scan that window.
Sign in to take notes on this problem
Accepts: array
Accepts: number
Max pooling is a downsampling operation commonly used in convolutional neural networks. It reduces the spatial dimensions of a feature map by selecting the maximum value within non-overlapping rectangular regions (pools). This helps reduce computation, extract dominant features, and provide a degree of spatial invariance.
Given a 2D matrix and a pool size, apply max pooling with non-overlapping windows (stride equal to pool size).
Return the pooled two-dimensional list.
Input: X = [[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12], [13, 14, 15, 16]], pool_size = 2
Output: [[6, 8], [14, 16]]
Explanation: Each non-overlapping 2 by 2 block contributes its maximum.
Input: X = [[1, 2, 3, 4, 5, 6], [7, 8, 9, 10, 11, 12], [13, 14, 15, 16, 17, 18], [19, 20, 21, 22, 23, 24], [25, 26, 27, 28, 29, 30], [31, 32, 33, 34, 35, 36]], pool_size = 3
Output: [[15, 18], [33, 36]]
Use integer division to count complete pooling windows along each dimension.
Initialize each maximum from the window’s top-left value, then scan that window.
Sign in to take notes on this problem
Accepts: array
Accepts: number