The Convolution Operation
Mathematical foundations of discrete convolution for neural networks: 1D and 2D convolutions as linear operators, equivariance to translation, the relationship between convolution and matrix multiplication, stride, padding, and receptive fields.
Table of Contents
- Learning Objectives
- Notation
- Core Intuition
- 1D Discrete Convolution
- 2D Convolution for Images
- Convolution as Matrix Multiplication
- Translation Equivariance
- Stride and Padding
- Multi-Channel Convolutions
- Receptive Field Analysis
- Backpropagation Through Convolution
- Common Pitfalls
- Summary
- Exercises
Learning Objectives
- Define discrete convolution and cross-correlation; explain the distinction.
- Express 2D convolution as a matrix-vector product using doubly-block Toeplitz matrices.
- Prove translation equivariance of the convolution operator.
- Derive output dimensions for given kernel size, stride, and padding.
- Compute the receptive field of deep convolutional architectures.
- Derive the gradient of the loss with respect to convolution weights (backprop through conv).
Notation
- — 1D input signal
- — kernel (filter) of size
- — convolution output
- — 2D input (single channel)
- — 2D kernel
- — stride, — padding
- — input/output channels
Core Intuition
Convolution is a linear operation that slides a small "template" (kernel) over the input, computing a weighted sum at each position. It encodes two inductive biases: locality (each output depends on a small input region) and weight sharing (the same kernel is applied everywhere). These biases make CNNs extremely parameter-efficient for spatial data.
2D Convolution
1D Discrete Convolution
Definition (Cross-Correlation). In deep learning, "convolution" is technically cross-correlation:
True convolution flips the kernel: . Since kernels are learned, the flip is immaterial — both learn the same filters.
Output size for input length , kernel size , no padding:
2D Convolution for Images
For input and kernel :
Output dimensions:
Convolution as Matrix Multiplication
The convolution in (1) is a linear operation and can be written as where is a Toeplitz matrix:
Each row is a shifted copy of the kernel weights. For 2D: the matrix is doubly-block Toeplitz. This viewpoint makes it clear that convolution is a special case of matrix multiplication with structured weight sharing.
Parameter count: A fully-connected layer mapping needs parameters. A convolutional layer needs only (per channel pair) — a massive reduction.
Translation Equivariance
Definition. An operator is equivariant to translation if: .
Theorem. Convolution is translation equivariant.
Proof. Let . Then:
Shifting the input shifts the output by the same amount.
Implication: A feature detected at one spatial location will be detected identically at any other location, without needing to learn separate detectors.
Stride and Padding
Stride : Sample the output every positions:
Output size: .
Padding : Append zeros to each side of the input. With padding:
"Same" padding: Choose such that . For : .
Multi-Channel Convolutions
Input: . Kernel: .
Each output channel uses a different kernel. Total parameters: .
Receptive Field Analysis
The receptive field of a neuron at layer is the input region that can influence its value.
For a stack of convolutional layers with kernel size and stride 1:
With stride at each layer:
Larger receptive fields capture more global context. Deeper networks or dilated convolutions increase RF without increasing parameters.
Backpropagation Through Convolution
Given (gradient w.r.t. output), we need:
Gradient w.r.t. weights:
This is itself a convolution of the input with the output gradient.
Gradient w.r.t. input:
This is a full convolution (with padding) of the output gradient with the flipped kernel — the "transposed convolution."
Common Pitfalls
Pitfall 1. Confusing convolution with cross-correlation. In practice, all deep learning frameworks implement cross-correlation but call it "convolution."
Pitfall 2. Forgetting that pooling breaks strict equivariance. Max-pooling with stride 2 introduces approximate (not exact) translation invariance.
Pitfall 3. Not accounting for receptive field limitations. If the RF is smaller than the relevant structure in the data, the network cannot capture it.
Summary
- Convolution slides a learned kernel over input, computing local weighted sums.
- Encodes locality and weight sharing — reducing parameters by orders of magnitude.
- Translation equivariant: detecting a feature anywhere requires only one kernel.
- Expressible as Toeplitz matrix multiplication.
- Backprop through conv = convolution with flipped kernel.
- Receptive field grows linearly with depth (or faster with stride/dilation).
Exercises
Exercise 1. Compute the output of a 1D convolution with input and kernel .
Exercise 2. Derive the output dimensions for a 2D convolution with .
Exercise 3. Construct the Toeplitz matrix for a 1D kernel applied to a length-5 input.
Exercise 4. Prove that the composition of two convolutions (without nonlinearity) is equivalent to a single convolution with a larger kernel.
Exercise 5. Compute the receptive field of a VGG-style network with 5 layers of kernels and stride 1.