Example

Example of Two-Dimensional Cross-Correlation

To illustrate a two-dimensional cross-correlation operation, consider a 3×33 \times 3 input tensor and a 2×22 \times 2 kernel tensor. Let the input be [012345678]\begin{bmatrix} 0 & 1 & 2 3 & 4 & 5 6 & 7 & 8 \end{bmatrix} and the kernel be [0123]\begin{bmatrix} 0 & 1 2 & 3 \end{bmatrix}. The convolution window begins at the upper-left corner of the input. The input subtensor within this window and the kernel are multiplied elementwise, and the products are summed to yield a single scalar value: 0×0+1×1+3×2+4×3=190 \times 0 + 1 \times 1 + 3 \times 2 + 4 \times 3 = 19. As the window slides across the input tensor from left to right and top to bottom, this process is repeated. The resulting output tensor has a shape of 2×22 \times 2 and contains the four derived scalar values, forming the matrix [19253743]\begin{bmatrix} 19 & 25 37 & 43 \end{bmatrix}.

Image 0

0

1

Updated 2026-06-29

Tags

D2L

Dive into Deep Learning @ D2L