3.4.2 · D1Convolutional Neural Networks

Foundations — Stride, padding, and dilation

1,982 words9 min readBack to topic

This page is the ground floor. The parent note Stride, padding, and dilation throws symbols like , , , , , and at you fast. Here we earn every one of them from a blank page, in an order where each idea leans on the one before it. If you have never seen a convolution, start at line one.


0. The grid: what "an image" even is

Before any symbol, a picture. A digital image is not a photo — to a computer it is a grid of numbers. Each little square (a pixel) holds one number (brightness). We line them up in rows and columns, like graph paper.

Figure — Stride, padding, and dilation

Look at the figure: the top-left cell is at position , and we count moving right. This "start at zero" choice is why a later formula ends in — we will meet that surprise head-on.


1. and — the input's width and height

Picture: in the figure above, the grid is cells across, so . Count top to bottom for .

Why the topic needs it: everything the parent note does is bookkeeping about size — you feed in a grid of a known size and you want to know the size that comes out. is the starting number in that arithmetic. We use width and height separately because an image can be a rectangle, but every formula is identical for both, so we usually just track width and copy the result.


2. — the kernel and its size

Picture: the amber square in the next figure is a kernel () sitting on top of the input.

Figure — Stride, padding, and dilation

What "sliding" means: we place the kernel over a patch of the image, multiply each kernel number by the pixel under it, add all those products into one output number, then slide the kernel to the next spot and repeat. Every landing spot produces exactly one output cell.

Why the topic needs : the kernel must fit entirely inside the image at every landing spot. A bigger means fewer spots fit, so directly shrinks the output. That is the seed of the whole output-size formula.


3. — stride, the step size

Picture: below, the same kernel lands at cells when — the amber outlines show the three landing positions, and the gaps between them are the skips.

Figure — Stride, padding, and dilation

Why the topic needs : stride changes how many landing positions exist. With bigger jumps you cover the same distance in fewer landings, so appears as a division in the output formula — dividing the room-to-move by the step size.


4. — padding, the added border

Picture: the cyan ring of zeros around the original grid in the next figure is padding with . The original grid is untouched inside; the padding just gives the kernel more room to land near the edges.

Figure — Stride, padding, and dilation

Why the ? We add cells on the left and cells on the right, so the width grows by in total. That is exactly why every formula uses : the effective width the kernel actually sees.


5. — dilation, the gaps inside the kernel

Picture: think of the kernel's cells as fingers of a hand. is fingers pressed together; spreads them so each finger touches a wider, sparser area of the image.

The span: a kernel has cells and gaps between them per row. Each gap is cells wide. So the total width the spread-out kernel covers is:

Here = effective kernel size: the width of the area the dilated kernel touches (even though it still holds only actual numbers).

Why the topic needs : in every size formula, dilation quietly replaces the plain with . Once you know , dilation needs no new formula — it just makes the kernel effectively bigger.


6. — the floor function, and the ""

Why we need it: the kernel can only land on whole cells — you cannot land halfway. If the leftover room does not divide evenly by the stride, the last partial step is simply lost, which is exactly "round down".

Why the mysterious : because we count starting from position . If the kernel lands at cells , that is jumps but positions. The number of jumps is ; adding counts the starting spot too.

Putting §1–§6 together gives the parent's master formula, now with every symbol earned:


Prerequisite map

Grid of pixels start at 0

Win and Hin input size

Kernel and size k

Effective size keff

Dilation d

Stride s step size

Output size formula

Padding p border

Floor and plus one

Stride padding and dilation

Receptive Field Analysis

Pooling Layers

These same foundations power Convolutional Layer Basics, and the output-size reasoning feeds directly into Receptive Field Analysis, Pooling Layers, and — via dilation — Semantic Segmentation Architectures. How wide vs deep you stack these layers is the subject of Network Depth vs Width.


Equipment checklist

Cover the answers and test yourself. If any line surprises you, re-read its section above.

What number does a single pixel hold?
One value (its brightness / intensity).
Why do cell positions start at 0 and not 1?
Because the formulas count slack from position 0, which is what forces the final .
What does measure?
The width (number of cells across) of the input grid.
What is ?
The side length of the square kernel — a kernel is cells wide and tall.
What does the kernel produce at each landing?
Exactly one output number (sum of products with the pixels beneath it).
What does stride control?
How many cells the kernel jumps between landings — the number of landing positions.
Why does padding add (not ) to the width?
Because cells are added on the left AND on the right.
What does padding fix at the edges?
It lets edge/corner pixels be covered many times, so they get a fair vote, and stops the grid shrinking.
What does dilation insert?
empty gaps between neighbouring kernel cells.
Write the effective kernel size.
.
Why does dilation not change the parameter count?
The gaps are empty — the kernel still holds only real weights.
What does do?
Rounds down to the nearest whole number.
Why the in the output formula?
To count the starting landing position (position 0), since the division only counts jumps.
State the full output-size formula.
.