liveBook · Manning

Stride

As explained in Math and Architectures of Deep Learning

The step size with which a convolutional kernel moves across the input, affecting the output size in convolution and transposed convolution.

Stride is the number of input positions a convolution kernel advances after producing one output. With stride 1, the kernel stops at successive elements; with stride 2, it stops at every other element. Larger strides therefore sample fewer kernel positions and usually reduce output size. section 10.1 section 10.8

For a 1D input of size n, kernel size k, stride s, and valid padding, after m shifts the kernel's right edge is ms + (k − 1), which must not exceed n − 1. Each valid position emits one value, so output size follows from the largest permissible m. With p zeros padded on each side, replace n by n + 2p; apply the calculation independently along each dimension. section 10.2 section 10.1

Stride 1 versus stride 2

A size-3 averaging kernel over a length-7 array with valid padding produces outputs from overlapping windows. At stride 1, the window advances one element at a time; at stride 2, it advances two, visiting every other start position and producing fewer outputs. section 10.1

Figure 10.2 1D convolution with a local averaging kernel of size 3, stride 2, and valid padding

Compare the stride-2 slide stops with the stride-1 case to see how skipping start positions shortens the output. section 10.1

Stride generalizes to spatial and spatio-temporal convolution. A 3D stride vector [sT, sH, sW] sets the stepping interval through time, height, and width; every slide stop yields one output point. Transposed convolution reverses the output-size relationship: o′ = (n′ − 1)s + k − 2p. section 10.4 section 10.5.2

In PyTorch, stride is a convolution-layer parameter alongside kernel size and padding. `torch.nn.Conv1d` and `torch.nn.functional.conv1d` accept it directly. Pooling uses the same geometric idea: a 2 × 2 filter with stride 2 makes an output feature map half the input size. section 10.1.4 section 10.7

How Math and Architectures of Deep Learning covers it

How deep it goes
Derives 1D output size from kernel bounds, then extends stepping to multidimensional and transposed convolutions.
Examples
Uses length-7 1D averaging windows, 3D video-volume stepping, PyTorch Conv1d calls, and 2 × 2 stride-2 pooling.
What it assumes
Introduces stride through arrays, kernels, and sliding windows while relating convolution to linear combinations and matrix multiplication.
What you can do after
Apply it via PyTorch convolution or pooling parameters and calculate resulting convolution or transposed-convolution output sizes.
How it connects
Connects kernel size and padding to convolution output size, and connects pooling to feature-map downsampling.

Also explained in

Compare how 8 books explain stride →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Math and Architectures of Deep Learning. The section links point to the parts of the book it draws on.