← the late compiler
C_000375 · deep learning · intermediate

Stride and Padding

Stride is the step between filter applications; padding adds border values so filters can cover the edges.

Step 1 of 4

In words

What it is, why it matters, and what it is like.

Why am I learning this?

Stride and padding are the two controls that decide the size of a convolutional layer's output — and therefore the shape of the whole network. With them you can keep an image's dimensions intact as it passes through a layer, shrink it deliberately to cut computation, and design the resolution pyramid that lets a network see fine details early and broad context later. This topic is the foundation for Convolution Arithmetic (the formula that predicts output sizes), and it unlocks the study of pooling, receptive fields, and the way modern vision models like CNNs and even transformers process images. Learn it now and you will never be surprised by a layer's output shape again.

The idea, in plain terms

Imagine you have a 5×5 grid of pixels — a small image. You want to examine it through a small window (the filter) that is 3×3. You can slide this window across the image. Two decisions control your scanning: how far you step each time (stride) and whether you can peek beyond the edges (padding).

If you step one pixel at a time, you will visit many positions; if you step two pixels at a time, you skip some and visit fewer. If you don't allow peeking beyond the edges, the window stops when it touches the border — so the map of visited positions is smaller than the original. If you add a border of zeros (padding), the window can extend past the original edge, letting it start right at the boundary and produce an output map the same size as the input.

Stride is the step length. Padding is the border filler. Together they determine exactly how many positions the window visits — the size of the output map.

An analogy

Think of reading a book with a magnifying glass. The glass is a 3×3 window. You move it across a page line by line. If you move it one character at a time, you examine every character — but that takes many positions. If you move it two characters at a time, you skip every second character and finish faster, but you see less detail. That's stride.

Padding is like extending the margins of the page. Without padding, the glass cannot cover the first character if it must be fully on the page — it starts at position 2, and the last character is never seen. If you add a blank margin of zeros (or any filler) around the page, the glass can start at position 1 and cover every edge character, producing a map with the same number of positions as there are characters.

Where the analogy breaks: in reading, you would not want to skip characters — you'd lose meaning. But in a neural network, skipping (stride > 1) is often desirable because it compresses information and reduces computation. Also, padding with zeros is not exactly like having extra plain margin — the filter still produces a number at those padding positions, and that number may contribute to later layers.

Definition

Stride is the step size between successive positions of a filter as it moves across an input; padding is the addition of extra border values (often zeros) around the input so that the filter can cover the edges without reducing the output size.

Where this sits

This concept sits inside Convolutional Networks. Your library notes on neighbouring topics will be directly used here: Convolution Arithmetic gives the formula for output size that uses stride and padding; Receptive Fields are affected by stride because larger strides skip positions and shrink the field of view of deeper units; and Pooling as a Statistic is a different way to downsample, but stride alone can do the same job. You have no prior concepts that are prerequisites — this is one of the first building blocks of CNNs. Once you master it, you can move on to Convolutional Layers and the full Convolution Arithmetic.

Signal from the Frontier

Get the next essay on mind, machine, and meaning

Essays at the intersection of AI, philosophy, and Indian governance. No promotional content.

We'll send a one-click sign-in link to confirm. No password needed.

Views expressed are personal and do not represent the Government of India or the Government of Uttarakhand.