Lai Learns Neural Networks

Lesson 23·Architecture·4 min read

From Brick to Wall, from Wall to Cathedral

Feature hierarchies and pooling: building big ideas out of small ones

“I once stood beneath the vault of a great cathedral and wept, not at its size, but at the thought of the mason who laid a single grey stone seven centuries before, never to see the arch it would one day hold aloft. All grandeur is only patience, piled upon itself.”

Invented, in the spirit of Stefan Zweig

Welcome back

Last time, we went birdwatching and met convolutional networks. Small filters slide across an image patch by patch, reusing the same weights everywhere, and each one learns to spot a single local clue, such as an edge or a dab of colour.

But spotting an edge is a long way from recognising a bird. Today we’ll see how a network gets from one to the other, and the answer looks a lot like how cathedrals get built.

Brick by brick

Walk around an old cathedral slowly. Look closely and you’ll see that it’s made of simple bricks and blocks of stone. A few bricks form a wall. Walls with an opening form an arch. Arches in a row form an aisle. Aisles, towers and a great vault together form the cathedral.

No single brick knows it’s part of a cathedral. Each level is built only from the level below, and each level is a little bigger and more meaningful than the one before.

Layers upon layers of seeing

A convolutional network stacks its layers in the same way, and each layer’s filters look at the feature maps made by the layer before.

This ladder from simple to complex is called a feature hierarchy. Nobody designed it. It emerges on its own during training, because building big ideas out of smaller ones is simply the most efficient way to reduce the loss. Researchers who peek inside trained networks really do find edge detectors near the bottom and something close to “face detectors” near the top.

Stepping back to see the whole

There’s a puzzle, though. A filter only sees a small patch. How does a later layer ever take in something as large as a whole bird?

Part of the answer is stacking: each layer looks at a patch of the previous layer’s map, which itself summarised a patch, so the view widens as you climb. The other part is a simple step called pooling.

Pooling shrinks a feature map by summarising small neighbourhoods. The most common kind, max pooling, looks at each little 2-by-2 square and keeps only the strongest value. It’s like an architect stepping back from the scaffolding. She loses some brick-level detail, but now sees the shape of the whole wall.

Pooling brings three gifts:

  1. A wider view. After pooling, each step of the next filter covers more of the original image.
  2. Less to compute. A 2-by-2 pool keeps just one value in four, so the maps get smaller and faster to work with.
  3. A little forgiveness. If a feature shifts by a pixel or two, the strongest value in its neighbourhood barely changes. The network cares that the beak is there, not its exact pixel.

What to carry with you

In one line

Stacked convolutional layers form a feature hierarchy, from edges to shapes to parts to whole objects. Pooling summarises small neighbourhoods so later layers can see more of the picture and forgive small shifts.

Next time

We’ll sit around a campfire as night falls. A good storyteller remembers what happened earlier in the tale. We’ll learn about recurrent networks, which carry a memory as they read through a sequence, one step at a time.