ContentsThe library

How a Filter Reads a Picture

Where the Window Fits, and How Often It Stops

Last timeWhy the Same Weights Everywhere

Two small choices decide the size of what comes out: what to do where the window hangs off the edge, and whether to use every position or every second one.

A three-wide window on a row of a hundred values fits in ninety eight places,

not a hundred. Two positions have been lost, one at each end, because at the very

first position the window would need a value to the left of the first and there

is none. In one dimension with a three-wide window that is a trivial loss. Stack

twenty layers of it in two dimensions and a two hundred and twenty four pixel

picture has shrunk to a hundred and eighty four, for no reason anybody intended.

FIG 1The output size, in full
the input size along one axis, in positions
the padding added to each side, so 2p in total
the window width along that axis
the stride, how far the window moves between uses
round down, because a partial step does not give a position
Every term answers a question. Padding widens the row, subtracting the window width accounts for the window needing to fit, dividing by the stride counts only the positions actually used, and the final one is the first position, which exists before any stepping happens.

The rounding down is where the surprises live. If the stride does not divide the

available span, the last partial step is simply not taken, and a strip at the far

edge of the input is read by no window at all. Nothing warns about this. It is

the reason two implementations of the same architecture can disagree by one pixel

and the reason a network sometimes behaves slightly differently on the right

side of an image than the left.

FIG 2The formula on five settings
input sizewindowpaddingstrideoutput size
no padding, every positi3230130
size preserving3231132
size preserving, every s3231216
wider window, every seco3252216
no padding, every third3230310
The marked row is the convention almost every modern design uses for its ordinary layers: the window is three, the padding is one, the stride is one, and the size is untouched. Resolution is then changed deliberately in separate places rather than leaking away one or two pixels at a time.

Padding, and the two reasons for it

The first reason is the one just given. Without padding, every layer shrinks the

picture, and in a deep network that shrinkage compounds until there is nothing

left to convolve. Padding of one with a three-wide window gives back exactly the

two positions that were lost.

The lesson stops here

4 more paragraphs to go

You have read the opening. The rest of the argument, the problems that check whether it landed, and the lines worth keeping at the end all come with a plan.

The first lesson of every course in the library reads the whole way through, free, so you can see exactly what the rest of them are.

See the planThe contents

This is the reading half

Starting the course gives you your own copy of it. Every idea on every page has problems standing under it, marked with a reason rather than a tick, and any sentence you do not believe can be opened and argued with. None of that can happen on a page nobody owns.

The contents

The rest of this course

  1. 01The Same Few Numbers, Everywhere
  2. 02The Constraint That Pays for Itselfopening only
  3. 03Where the Window Fits, and How Often It Stopsyou are here
  4. 04One Filter Is Never Enoughopening only
  5. 05The Slow Widening of the Viewopening only
  6. 06Throwing Away Where, to Keep Whatopening only
  7. 07Two Discounts, Each With a Conditionopening only
  8. 08It Was a Matrix Multiply All Alongopening only

Read alongside