Max pooling shrinks feature maps in CNNs by keeping the largest value in each window.
Implement max_pool2d(x, kernel, stride=None):
x has shape (channels, height, width).kernel is the window size (square). stride defaults to kernel.(channels, out_h, out_w). Pool each channel independently.Example
max_pool2d(np.array([[[1, 2, 5, 6], [3, 4, 7, 8], [9, 1, 2, 3], [4, 5, 0, 1]]]), 2)
# array([[[4, 8], [9, 3]]])