Example

Centered Layer

A practical example of a custom parameterless layer is a centered layer, which normalizes its input by subtracting the mean of the input tensor from each of its elements. Mathematically, for an input tensor X\mathbf{X}, the forward propagation of this layer computes Xmean(X)\mathbf{X} - \text{mean}(\mathbf{X}). This operation ensures that the output tensor always has a mean of exactly 0 (subject to minor floating-point quantization errors).

0

1

Updated 2026-06-19

Tags

D2L

Dive into Deep Learning @ D2L