2D Average Pooling
Core Vision Operations DS practice problem on Onlearn.
Difficulty: medium.
Topics: Understanding Spatial Downsampling via Average Pooling, Kernel Size, Stride Dynamics, Padding Strategies, Floating Point Aggregation, Matrix Reshaping, Receptive Field Calculation, Computer Vision, Linear Algebra, Signal Processing, Neural Network Architectures, Numerical Computing, Feature Map Reduction, Spatial Invariance, Convolutional Layers, Downsampling Techniques, Windowing Functions.
Implement a 2D Average Pooling function that takes a 2D matrix (as a list of lists), a kernel size, and a stride. The function should perform downsampling by calculating the mean of each non overlapping or overlapping window. Assume the input is a square matrix and the kernel size perfectly divides the input dimension unless specified otherwise.