Code

Two-Dimensional Pooling Layer Code Implementation

The forward propagation of a two-dimensional pooling layer can be implemented programmatically without using a kernel. A function pool2d(X, pool_size, mode) iterates over the input tensor X with a sliding window defined by pool_size. At each location, it extracts the sub-tensor and computes either its maximum or mean, depending on the mode parameter. Unlike cross-correlation, this computation relies purely on deterministic aggregation over the input regions rather than learnable parameters.

0

1

Updated 2026-05-12

Contributors are:

Who are from:

Tags

D2L

Dive into Deep Learning @ D2L