Example

Evaluating Two-Dimensional Pooling Layer Implementation

To validate the programmatic implementation of a two-dimensional pooling layer, one can evaluate the pool2d function using a known input tensor. For instance, consider a 3imes33 imes 3 input tensor X populated with sequential values from 00 to 88. Applying a 2imes22 imes 2 max-pooling layer (the default mode in the implementation) slides the window across the tensor, outputting the maximum value in each 2imes22 imes 2 region. This results in a 2imes22 imes 2 output tensor with elements 44, 55, 77, and 88. Conversely, passing the 'avg' mode argument to the same function calculates the average for each region, producing a 2imes22 imes 2 tensor with elements 22, 33, 55, and 66. This practical evaluation confirms that the custom function correctly computes both max and average deterministic aggregations across the input subtensors.

0

1

Updated 2026-05-12

Contributors are:

Who are from:

Tags

D2L

Dive into Deep Learning @ D2L