Max pooling is a downsampling operation commonly used in convolutional neural networks to reduce spatial dimensions while retaining the most prominent features. It slides a window over the input and takes the maximum value in each window position.
Given a 2D input matrix X (height H, width W), a pool size p, and a stride s, compute the max pooling output.
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, stride = 2
Output: [[6, 8], [14, 16]]
Explanation: Each non-overlapping 2 by 2 window contributes its maximum.
Input: X = [[1, 5, 3], [4, 2, 6], [7, 8, 0]], pool_size = 2, stride = 1
Output: [[5, 6], [8, 8]]
Compute output height and width with integer division before scanning windows.
Initialize a window maximum from its top-left value, then compare the remaining entries.
Sign in to take notes on this problem
Accepts: array
Accepts: number
Accepts: number
Max pooling is a downsampling operation commonly used in convolutional neural networks to reduce spatial dimensions while retaining the most prominent features. It slides a window over the input and takes the maximum value in each window position.
Given a 2D input matrix X (height H, width W), a pool size p, and a stride s, compute the max pooling output.
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, stride = 2
Output: [[6, 8], [14, 16]]
Explanation: Each non-overlapping 2 by 2 window contributes its maximum.
Input: X = [[1, 5, 3], [4, 2, 6], [7, 8, 0]], pool_size = 2, stride = 1
Output: [[5, 6], [8, 8]]
Compute output height and width with integer division before scanning windows.
Initialize a window maximum from its top-left value, then compare the remaining entries.
Sign in to take notes on this problem
Accepts: array
Accepts: number
Accepts: number