DEEP LEARNINGPresentation & practice sheets
0 of 11 sections complete0%
← All presentation & practice sheets
CONVOLUTIONAL NETWORKS

See locally,
share globally.

An image is not a bag of pixels. Nearby pixels belong together, and the same pattern can appear anywhere.

10 visual labsOne image, many ideasTyped checks
01 / NOTICEA question, then a picture of the problem.
02 / EXPLOREAn analogy, a formula, then a live experiment.
03 / EXPLAINAnswer the questions. Unfold the detail when you need it.

Numbers mode · small matrices you can calculate by hand.

Use the Numbers / Images button above to switch every illustration and lab. Image mode uses a real handwritten 7. Pixel values stay visible; teal and coral distinguish positive and negative filter responses.

Examples use fixed filters, one channel and no bias unless stated. Real CNNs learn filters. Questions use their own stated values.

00
WHY CONVOLUTIONAL NETWORKS?

Same pattern.
Different place.

Complete ✓
01 / THE QUESTION

If a handwritten 7 moves across the page, should the network have to learn it all over again?

02 / SEE THE PROBLEM
The same strokes move to different pixel addresses. A dense layer gives those addresses separate weights; the picture still means “7”.
03 / THE IDEA

Before CNNs became widely used, image recognition often meant hand-designed features plus a classifier, or a fully connected network on flattened pixels. The architectural question: what should the model assume about an image?

Think of a reusable stencil. Local connections let it inspect a small neighbourhood; weight sharing lets the same stencil search the whole page. Stacking these detectors lets strokes become parts, then objects.

Hand-designed features + classifier

People choose edges, textures or descriptors; a classifier learns how to use them. Feature design and classification are separate.

Fully connected network

Can learn features, but assigns separate weights to each input/output pair. Locality and translation sharing must be learned from examples.

Convolutional network

Learned local detectors are reused across space. Deeper layers combine their responses into larger patterns.

04 / THE FORMULAFormula & notation
Dense: (H · W · Cin) · (Hout · Wout · Cout)
Convolution: K² · Cin · CoutWeight counts, excluding biases · compare the same output shape

H, W: input height and width · K: kernel side · C: channel count · “out”: output dimensions.

Go deeperTheory, formula walkthrough & worked examples

A flattened image still contains all its pixels. What a dense layer lacks is a built-in rule for neighbourhoods and shared detectors. A locally connected layer adds neighbourhoods, but still has separate weights at each output location. Convolution adds weight sharing as well. The smaller parameter count is an inductive bias, not a guarantee that every vision problem needs a CNN.

Why locality and sharing are separate decisions

This story predates AlexNet: LeNet demonstrated learned convolutional features for document recognition in the 1990s. AlexNet later scaled CNN training to ImageNet with GPUs, ReLU and regularisation.

For 32×32 → 30×30 with one channel: dense = 921,600 weights; local but unshared = 8,100; convolution = 9. Compute still increases with the number of output locations, even when parameter count does not.

05 / TRY IT

What does one detector cost?

EXPLORE

The small grid shows a sample patch. The counter uses the image size you select.

YOUR EXPERIMENT

Scale the image.

One input channel, one output channel, 3×3 kernel, stride 1, no padding. All three architectures produce (H − 2)² outputs.

TRY THIS

Double the image side. Which design keeps the same number of weights?

06 / CHECK YOUR UNDERSTANDING
Check your understanding

A 32×32 input has 1,024 pixels. A 3×3 valid convolution produces 30×30 = 900 outputs. A dense layer to those 900 outputs needs weights. One shared 3×3 filter needs . Which idea lets a detector work at every location: locality or sharing?

Show answer

1,024 × 900 = 921,600; 3 × 3 = 9; weight sharing. Local connectivity alone uses 9 × 900 = 8,100 separate weights.

01
FILTERS / KERNELS

A small template.
A sliding inner product.

Complete ✓
01 / THE QUESTION

A pixel is bright. Is it an edge, part of a stroke, or just a flat patch?

02 / SEE THE PROBLEM
A single bright value cannot tell you whether a boundary is nearby. Compare it with its neighbours.
03 / THE IDEA

A kernel is a small stencil with a score: multiply its weights by the covered pixels, then add. Slide the same stencil to find the same pattern in a new location.

04 / THE FORMULAFormula & notation
zij = Σuv Kuv xi+u, j+vOne output cell · valid placement · one input channel
Go deeperTheory, formula walkthrough & worked examples

Read the sum. The indices u, v run over the kernel. i, j choose where the top-left of the kernel sits on the input. Every output cell uses the same K. If you had a different K at every location you would have built a locally connected layer with unshared weights, and you would have lost translation sharing. A bias b, when present, is added after the sum and is also shared across space.

Three things to separate

  1. The arithmetic

    Each placement is an inner product. If you can do one by hand, you can do the layer.

  2. The sharing

    The kernel does not change as it moves. Different output cells are different patches, not different detectors.

  3. The meaning

    Learned kernels become texture and part detectors. The presets here are the classical ones, so you can predict the map.

WORKED NUMERICAL EXAMPLE

On a 7×7 input with a 3×3 kernel, stride 1 and no padding, there are 5×5 = 25 placements. Each uses the same nine weights. The lab highlights one placement at a time and writes the inner product on the output grid.

Predict before you play: Will the vertical-edge kernel fire in the middle of the left-hand block of 1s?

No. Inside a constant block every 3×3 of 1s gives 1+1+1 − (1+1+1) = 0. The kernel fires at the light-to-dark transition.

WHAT TO LOOK FOR

In Numbers mode, the edge response is zero inside a constant block and nonzero at its boundaries. In Images mode, compare that response with the strokes of the handwritten 7. The coral frame marks the current patch, regardless of its response.

Key idea

Weight sharing is not a trick for speed only. It is the claim that the world is stationary: the same pattern is legal everywhere.

Common mistake

“Convolution in deep learning is the same as the mathematical convolution.” Libraries implement cross-correlation: they do not flip the kernel. The name stuck. For learning, an unflipped kernel is simply a different parameterisation.

05 / TRY IT
2D GRID / SLIDING KERNEL

One patch at a time.

INTERACTIVE
The coral frame is the current patch

Every cell shows its value. The expanded inspector below keeps more decimal places.

YOUR EXPERIMENT

Choose a detector.

TRY THIS

Predict the edge-x map, then switch the kernel. Does blur shrink the jump at the boundary?

06 / CHECK YOUR UNDERSTANDING

Use this fixed numerical example for the questions below, in either visual mode.

Try it by hand

Row 1 contributes . Row 2 contributes . Row 3 contributes . The output pixel is .

Show answer

1·1 + 2·0 + 0·(−1) = 1. Then 0 + 0 − 2 = −2. Then 3 + 0 − 1 = 2. Total 1 − 2 + 2 = 1. An edge kernel of this shape is a vertical first difference: bright on the left, dark on the right, gives a positive response.

02
STRIDE

How far the
template hops.

Complete ✓
01 / THE QUESTION

Scanning every possible patch is expensive. What detail do we lose when we take bigger steps?

02 / SEE THE PROBLEM
The same input is sampled densely or sparsely. Skipped window centres can miss a narrow stroke.
03 / THE IDEA

Imagine reading a tiled floor by stepping on every tile, then every second tile. Stride is the step size of the detector; larger steps produce a smaller output grid.

04 / THE FORMULAFormula & notation
Hout = ⌊(H + 2P − K)/S⌋ + 1Integer division · independent of the kernel values
Go deeperTheory, formula walkthrough & worked examples

Read the hop. Increasing S makes the output smaller and makes each output cell look at a patch whose top-left is farther from its neighbours. The receptive-field jump (Part 6) is multiplied by S. A large stride in the first layer, as in AlexNet, is a deliberate decision to throw away fine spatial grid while keeping a large field of view.

Skipped origins are simply not computed

  1. Start at (0,0)

    Then add S to the row or column until the kernel would hang off the (padded) input.

  2. The formula is not optional

    If (H + 2P − K) is not divisible by S, the leftover border is unused. That is what the floor is for.

  3. Do not confuse with pooling

    Stride in a convolution still computes a learned inner product. Pooling (Part 5) summarises a patch with max or mean and has no kernel weights.

WORKED NUMERICAL EXAMPLE

AlexNet’s first layer: H = 227, K = 11, S = 4, P = 0. Hout = ⌊(227 − 11)/4⌋ + 1 = 55. A 224-pixel input with P = 2 also gives 55; with P = 0 it gives 54. State the input and padding convention together.

Predict before you play: If we raise stride from 1 to 2 on the 7×7 blob, does any output cell still see the peak?

With the identity kernel, only the centre pixel contributes. Here the peak is at (3,3), and stride 2 still samples that centre. A different alignment could miss it even if the window covers it.

WHAT TO LOOK FOR

The output grid should shrink as you drag stride. Count the coral visits: 25, then 9, then 4.

05 / TRY IT
2D GRID / STRIDE

Fewer hops, smaller map.

Identity kernel, so the output copies each window centre

Stride 2 and 3 hop directly between sampled origins; skipped origins are never evaluated. The identity kernel copies each selected centre pixel.

YOUR EXPERIMENT

Change the hop.

TRY THIS

Set S = 2. How many output cells remain? Check it against the formula.

06 / CHECK YOUR UNDERSTANDING
Try it by hand

Same H = 7, K = 3, P = 0. Stride 1 gives Hout = . Stride 2 gives . Stride 3 gives .

Show answer

⌊(7 − 3)/1⌋ + 1 = 5. ⌊4/2⌋ + 1 = 3. ⌊4/3⌋ + 1 = 2. The origins for stride 2 are (0,0), (0,2), (0,4) and the three matching rows 2 and 4 — nine visits, not 25.

03
PADDING

Keep the border
in the conversation.

Complete ✓
01 / THE QUESTION

Why does a perfectly ordinary 3×3 filter make the image smaller after every layer?

02 / SEE THE PROBLEM
Without a border, a 3×3 window cannot be centred on the outermost pixels. Repeated layers shrink the available map.
03 / THE IDEA

Add a temporary frame around a photograph so the stencil can reach its edges. Zero padding supplies that frame; it preserves size for an odd kernel at stride 1 when P = (K − 1)/2.

04 / THE FORMULAFormula & notation
Psame = (K − 1)/2Odd kernels, stride 1 · VGG’s default
Go deeperTheory, formula walkthrough & worked examples

Read the halo. Padding is not a trick to invent data. It is a decision about whether corner pixels get to be window centres. Without it, every layer eats the border and a deep stack silently crops the image. With it, spatial size stays a design choice of stride and pooling, not of kernel size. Zero padding is the default; it can create a faint “border artefact” that later layers sometimes exploit.

Zeros around the picture

  1. Write the padded array

    A 2×2 block with P = 1 becomes 4×4, with the original numbers in the centre and zeros on the rim.

  2. Run the usual formula on the padded size

    H′ = H + 2P, then Hout = ⌊(H′ − K)/S⌋ + 1, which is the same as the compact formula.

  3. Same is a policy, not a miracle

    It holds for stride 1 and odd K. Stride 2 with “same” padding in frameworks is a slightly different rounding convention; always print the tensor shape.

WORKED NUMERICAL EXAMPLE

Input [[1,2],[3,4]] with P = 1. The padded grid is a 4×4 of zeros with that block in the centre. A 3×3 identity then returns a 2×2 — the original image — because each original pixel can sit at a window centre.

Predict before you play: With P = 1 on the 7×7 blob, is the output 7×7 or 9×9?

7×7. Padding adds two rows, the 3×3 then removes two, and you are back to 7. You do not keep the extra halo in the output.

WHAT TO LOOK FOR

Padding cells contain zeros (pale in Numbers mode, black in Images mode). P = 1 restores the original height and width for this stride-1 3×3 layer.

05 / TRY IT
2D GRID / PADDING

A halo of zeros.

Identity kernel again, so size changes are the whole story

The input drawn here includes the padded zeros when P > 0.

YOUR EXPERIMENT

Add a border.

TRY THIS

Set P = 1 and compare input and output sizes. Then try P = 2: the output grows.

06 / CHECK YOUR UNDERSTANDING
Try it by hand

For H = 5, K = 3, S = 1, the P that keeps Hout = 5 is . For H = 7, K = 5, S = 1, P = . With H = 7, K = 3, S = 1, P = 0, Hout = .

Show answer

P = (3−1)/2 = 1 and (5−1)/2 = 2. Unpadded 7 with 3×3 is ⌊(7−3)/1⌋+1 = 5, which is why the identity lab without padding loses a one-pixel frame.

04
FEATURE MAPS

One kernel,
one channel.

Complete ✓
01 / THE QUESTION

One detector sees vertical strokes. Who notices the horizontal strokes or smooth regions?

02 / SEE THE PROBLEM
One filter leaves out other useful patterns. Different filters turn the same image into different response maps.
03 / THE IDEA

Think of a team of specialists: one looks for vertical changes, another horizontal changes, another local brightness. Each writes a map; the next layer reads the whole stack.

04 / THE FORMULAFormula & notation
#params = Cout · Cin · K · K + Cout if you count biases
Go deeperTheory, formula walkthrough & worked examples

Read the volume. For a colour image Cin = 3 at the first layer. After that, Cin is whatever the previous layer emitted. Doubling Cout doubles both compute and parameters. Spatial size (H, W) does not appear in the parameter count — that is the point of sharing — but it does appear in the multiply-adds, which are Hout Wout times the parameter count, before bias.

Maps are stacked, not mixed in the drawing

  1. One detector, one plane

    Edge-x, edge-y and blur are three independent inner products. Early layers of a CNN learn similar low-level detectors, then mix them.

  2. Next layer sees the stack

    Its kernels have thickness Cin. A 3×3 “on 64 maps” is 64 × 3 × 3 = 576 weights per output channel.

  3. 1×1 convolutions

    K = 1 still mixes channels at a single location. That is a cheap learned change of C, used heavily after VGG (Network-in-Network, Inception, ResNet bottlenecks).

WORKED NUMERICAL EXAMPLE

In Numbers mode, a 7×7 input and three 3×3 filters give three 5×5 maps at stride 1 with no padding: a 5×5×3 volume. In Images mode the 8×8 digit gives a 6×6×3 volume. The kernels are fixed, so this illustrates a forward pass rather than training.

Predict before you play: Will the blur map look like a softer copy of the edge, or like a softer copy of the image?

A softer copy of the image. Blur averages the 3×3; it is not an edge detector. Edge-x should be quiet inside the white block and loud at the vertical jump.

WHAT TO LOOK FOR

Compare the three maps side by side. Thickness of the stack is the number of maps, not the spatial size.

05 / TRY IT
2D GRID / THREE MAPS

Same image, three stories.

COMPARE

Input → selected kernel → its output. Choose a map below to bring that detector into focus.

YOUR EXPERIMENT

Inspect a detector.

TRY THIS

Compare the same location in all three maps. Why do their responses differ?

06 / CHECK YOUR UNDERSTANDING
Try it by hand

16 kernels, 3 input channels, 3×3, no bias: weights. With a bias per kernel: . VGG’s first layer, 64 kernels on RGB 3×3, no bias: .

Show answer

16 × 3 × 9 = 432, plus 16 biases = 448. 64 × 3 × 9 = 1728. A fully connected layer from 224×224×3 to 64 maps of similar size would require hundreds of billions of weights; the convolution stays at 1728.

05
POOLING

Summarise,
then move on.

Complete ✓
01 / THE QUESTION

Do we need the exact location of every strong response, or can we keep a smaller summary?

02 / SEE THE PROBLEM
Many neighbouring responses describe the same local feature. A compact map must decide what to keep.
03 / THE IDEA

Like choosing one representative for each neighbourhood, max pooling keeps the strongest response. Average pooling keeps the mean. Neither learns weights; both trade spatial detail for a smaller map.

04 / THE FORMULAFormula & notation
y = max{ xwindow }   or   mean{ xwindow }Typical: 2×2, stride 2 · AlexNet used overlapping 3×3, stride 2
Go deeperTheory, formula walkthrough & worked examples

Read the summarise. Max pooling keeps the strongest detector response in the window and forgets where inside the window it was, up to the window size. Average pooling keeps mass instead of peaks. Neither replaces a convolution: you still need a learned kernel to decide what “strong” means. Modern nets (ResNet and after) often prefer stride-2 convolutions to explicit pooling in the main path, but the geometry is the same idea.

Downsample without new parameters

  1. Partition the map

    Non-overlapping 2×2 stride 2 is a partition. Overlapping 3×3 stride 2 (AlexNet) lets neighbouring windows share pixels.

  2. Reduce H and W, keep C

    Pooling is applied per feature map. You still have the same number of detectors, on a coarser grid.

  3. Invariance is local

    A 1-pixel shift that stays inside the same window can leave the max unchanged. A shift that crosses a window boundary does not. True invariance is built by stacking this with later layers, not by one pool.

WORKED NUMERICAL EXAMPLE

In the fixed 4×4 example in the questions below, the bottom-right window is [[8,1],[1,3]]. Max pooling gives 8, while average pooling gives 13/4 = 3.25. In Images mode the same operations act on the digit’s 8×8 pixel matrix.

Predict before you play: If we change the 8 to a 1, which max-pool cell changes?

Only the bottom-right, which becomes max(1,1,1,3)=3. The other three windows do not contain that entry.

WHAT TO LOOK FOR

Toggle max versus average. Max tracks peaks; average tracks mass. Neither redraws the 4×4 as a convolution would.

05 / TRY IT
2D GRID / POOLING

Four cells become one.

Coral: current 2×2

Pooling has no kernel grid to show — only the window and the summary.

YOUR EXPERIMENT

Max or mean.

TRY THIS

Compare max and average on the highlighted window. Which preserves the strongest stroke response?

06 / CHECK YOUR UNDERSTANDING

Use this fixed numerical example for the questions below, in either visual mode.

1320
4102
2281
0513
Try it by hand

2×2 max, stride 2. Top-left , top-right , bottom-left , bottom-right . Top-left average is .

Show answer

max(1,3,4,1)=4, max(2,0,0,2)=2, max(2,2,0,5)=5, max(8,1,1,3)=8. Average of the first window (1+3+4+1)/4 = 2.25.

06
RECEPTIVE FIELD

What can this
unit actually see?

Complete ✓
01 / THE QUESTION

A 3×3 detector sees a tiny patch. How can a deeper unit see a whole digit?

02 / SEE THE PROBLEM
The small window sees only part of the image. Combining neighbouring windows gives later units more context.
03 / THE IDEA

Imagine looking through overlapping windows: a window onto the previous layer covers several windows onto the original image. The receptive field tracks how far that view reaches.

04 / THE FORMULAFormula & notation
RFℓ = RFℓ−1 + (Kℓ − 1) · Jℓ−1,   Jℓ = Jℓ−1 · SℓStart from RF = 1, J = 1 on the pixels
Go deeperTheory, formula walkthrough & worked examples

Read the growth. Jump J is the spacing, in input pixels, between adjacent units at the current layer. A stride-2 layer doubles that spacing. Padding changes which pixels exist, not the theoretical field size of a unit in the bulk. A 1×1 convolution does not grow RF at all. Pooling with K = 2, S = 2 grows RF by 1 × J and then doubles J — the same recurrence, with no learned weights.

Field of view is designed, not accidental

  1. One 7×7 versus three 3×3

    Both have RF = 7 at stride 1. The stack uses 27 weights with one channel throughout instead of 49, and it inserts two extra nonlinearities.

  2. Stride multiplies jump

    After a downsample, further 3×3s grow the field faster, in input pixels, because each step is a larger jump.

  3. Effective field can be smaller

    The theoretical RF is the support. If weights in the corners are tiny, the practical field is concentrated in the centre. Dilated convolutions grow RF without a stride, by inserting holes in the kernel.

WORKED NUMERICAL EXAMPLE

Three stride-1 3×3 layers grow RF from 1 to 3 to 5 to 7. Set stride to 2 and the recurrence gives RF 3, 7, 15 and jumps 2, 4, 8. The lab clips a field larger than the displayed image; the table still reports the full theoretical size.

Predict before you play: Two 3×3 layers at stride 2 — is RF 5 or something larger?

Layer 1: RF = 3, J = 2. Layer 2: RF = 3 + 2×2 = 7, J = 4. Larger than two stride-1 layers (RF 5), because the second kernel steps in input pixels of size 2.

WHAT TO LOOK FOR

Read the table under the grid. RF and jump should match the recurrence, not the picture’s crop.

05 / TRY IT
2D GRID / FIELD OF VIEW

Grow the square.

Coral outlines the theoretical receptive field. Values are input pixels. When the field exceeds this image, the growth bars below show its full size.

LayerK / SRFJump
YOUR EXPERIMENT

Stack layers.

TRY THIS

Match three 3×3 stride-1 to one 7×7. Then give them stride 2 and watch jump take over.

06 / CHECK YOUR UNDERSTANDING
Try it by hand

Three stride-1 3×3 layers: RF = . AlexNet’s first layer, K = 11, S = 4: RF = and jump = . After one more 3×3 stride-1: RF = .

Show answer

1+2+2+2 = 7. First layer: RF = 11, J = 4. Then RF = 11 + 2×4 = 19, J stays 4. That is why an early large stride buys field of view quickly and spends spatial precision.

07
TRANSLATION

Move the object.
Move the features?

Complete ✓
01 / THE QUESTION

Move the digit one pixel. Should its feature map stay still, or move with it?

02 / SEE THE PROBLEM
The object is the same, but its pixel addresses change. Track what happens to the response, not just its peak value.
03 / THE IDEA

A tracking spotlight moves with its subject: that is equivariance. A label that still says “7” is invariant. Stride-1 convolution provides the first property away from boundary effects; the whole classifier must learn the second.

04 / THE FORMULAFormula & notation
f(TΔ x) = TΔ f(x)Equivariance of stride-1 convolution · T is a spatial shift
Go deeperTheory, formula walkthrough & worked examples

Read the commuting diagram. T_Δ slides the array. If you convolve then shift, you should get the same array as shift then convolve. Weight sharing is exactly what makes that true: the detector does not know it has moved. Fully connected layers do not commute with T_Δ, because each position has its own weights. Classification wants invariance at the end, not at the first layer — you still need to know that the ear is next to the eye.

Shift the input, compare the whole maps

  1. Equivariance first

    The identity convolution with P = 1 copies the image. Shifting the copy is the same as copying the shift. That is the cleanest picture of the property.

  2. Boundaries still matter

    Finite-image boundaries can break exact equivariance even with same padding. This lab leaves enough zero margin for every displayed shift, so its vertical-edge responses shift exactly with the input. Cropping the object or its surrounding context can break that equality.

  3. Then pool

    Max-pool after the shift is not always a shift of the pooled map. Pooling can leave some within-window shifts unchanged, but it does not guarantee invariance.

WORKED NUMERICAL EXAMPLE

In Numbers mode, slide the blob; in Images mode, slide the digit inside a zero border. With the vertical-edge filter and room to shift inside the zero margin, convolving the shifted input gives the shifted edge map. Compare all cells in the pooled maps before claiming that they stayed the same.

Predict before you play: If we shift by 2 pixels, does 2×2 max-pool stay identical?

Not necessarily. Two pixels is a whole pooling window, so the peaks move into a different output cell. A 1-pixel shift is the interesting case for local invariance.

WHAT TO LOOK FOR

The vertical-edge responses travel with the input. The zero margin keeps the demonstrated shifts inside the frame; cropping or a larger stride can change this relationship.

05 / TRY IT
2D GRID / SHIFT

The object moves. The detector follows.

Input shows pixel brightness. Convolution shows signed vertical-edge responses. Max pooling summarises those responses. Each pair uses the same colour scale.

YOUR EXPERIMENT

Slide the input.

TRY THIS

Set the shift to 1, then 2. Equivariance of conv should hold at both; pooling’s “sameness” should not.

06 / CHECK YOUR UNDERSTANDING
Try it by hand

Away from boundary effects, stride-1 convolution is translation . After a 1-pixel shift of the input, the feature map shifts by pixel. A fully connected layer on flattened pixels is, in general, .

Show answer

Equivariant; 1; neither (not equivariant, and not invariant). Pooling is a step toward invariance, locally, as in 5.1.

08
ALEXNET · 2012

The network that
made the field look up.

Complete ✓
01 / THE QUESTION

The building blocks exist. How do we turn them into a network that can recognise complex images?

02 / SEE THE PROBLEM
Raw pixels contain many local patterns. One edge map is useful evidence, but it is not yet an object class.
03 / THE IDEA

Think of an assembly line: convolution and ReLU build features, pooling reduces their spatial size, and a classifier combines the evidence. AlexNet paired this hierarchy with a training recipe that scaled in 2012.

04 / THE FORMULAFormula & notation
(227 − 11)/4 + 1 = 55227 input, 11×11 kernel, stride 4, no padding · 96 output maps
Go deeperTheory, formula walkthrough & worked examples

Read the first layer. An 11×11 kernel on RGB is 11×11×3 = 363 weights per map, times 96 maps — still tiny next to the later fully connected layers, which hold most of AlexNet’s 60 million parameters. The large stride is an aggressive downsample: jump 4 already, RF 11. Everything after that reasons on a 55×55 (then smaller) grid, not on the raw 227.

INPUT 227 × 227 × 3 CONV 11×11, S=4, 96 55 × 55 × 96 · ReLU · response norm · pool 3×3 S=2 CONV 5×5, 256 then pool CONV 3×3, 384 twice more at 384 and 256 · pool FC 4096 · FC 4096 · FC 1000 dropout on the 4096s · softmax
Key idea

AlexNet’s lessons that lasted: ReLU instead of saturating sigmoids, dropout on the large fully connected layers, heavy augmentation, and GPU training. Local response normalisation did not last. The fully connected tail is the parameter hog; VGG kept it, later nets replaced it with global average pooling.

Common mistake

“AlexNet is 8 learned layers, so it is small.” Depth is 8, but the last three layers are dense. Parameter count is not the same as convolutional depth. VGG-16 is deeper in convolution and even heavier in FC.

At the board What 2012 changed

Before AlexNet, the ILSVRC winner was typically a carefully engineered vision pipeline. After it, the default became: learn the features, use more data, use ReLU, regularise the dense layers. The architecture details were a snapshot. The training recipe was the revolution.

# First AlexNet-style conv in PyTorch (simplified)
nn.Conv2d(3, 96, kernel_size=11, stride=4, padding=0)
nn.ReLU(inplace=True)
nn.MaxPool2d(kernel_size=3, stride=2)
05 / TRY IT

Follow the feature pipeline.

EXPLORE

A small, computed teaching pipeline. These fixed filters are not trained AlexNet activations.

YOUR EXPERIMENT

Inspect a stage.

TRY THIS

Look for negative responses after convolution. Then select ReLU: which values survive? What changes after pooling?

06 / CHECK YOUR UNDERSTANDING
Try it by hand

First-layer Hout with 227, K = 11, S = 4, P = 0: . Weights in one 11×11 RGB kernel: . After that pool 3×3 stride 2, spatial size ≈ .

Show answer

55. 11×11×3 = 363. Pool: ⌊(55 − 3)/2⌋ + 1 = 27. (Some implementations use 27×27 after rounding conventions on 224-input variants.)

09
VGG · 2014

Only 3×3.
Just go deeper.

Complete ✓
01 / THE QUESTION

We need a 7×7 view. Must we pay for one large 7×7 filter?

02 / SEE THE PROBLEM
One small window misses context. One large window sees more, but uses more weights. Can depth offer another route?
03 / THE IDEA

Build a wider view one small window at a time. Three 3×3 layers at stride 1 reach a 7×7 region. With one channel throughout they use 27 weights versus 49; ReLUs between layers also change what functions can be represented.

04 / THE FORMULAFormula & notation
3 · (3 × 3) = 27   vs   7 × 7 = 49One channel throughout · no bias · same RF = 7 at stride 1
Go deeperTheory, formula walkthrough & worked examples

Read the bargain. A 5×5 is two 3×3 (RF 5, 18 vs 25 weights). A 7×7 is three 3×3. VGG uses that substitution everywhere, and uses channel widths (64-128-256-512-512). The spatial size of 224 is kept by P = 1 until a pool halves it. The design is a template: later residual nets kept 3×3 as the default atomic convolution.

Deeper, narrower kernels

  1. Match the field

    n layers of 3×3 at stride 1 give RF = 1 + 2n, so n = 3 matches 7×7.

  2. Count the weights

    n × 9 versus (1+2n)². For n > 1 the stack is cheaper, and the gap widens.

  3. Pay in depth

    More layers are harder to train (vanishing signal — see the initialization sheet). VGG still trained with the 2014 recipe. Residual connections later made this bargain even better.

WORKED NUMERICAL EXAMPLE

With n = 3, three 3×3 filters use 27 weights and cover a 7×7 region. One 7×7 filter uses 49 weights. These counts assume one channel throughout and no biases. With a fixed width C at every layer, both counts scale by C².

Predict before you play: At n = 4, is the large kernel 9×9?

Yes. RF = 1 + 8 = 9, weights 36 vs 81. The stack is less than half the price.

WHAT TO LOOK FOR

The two coral regions should match. For n > 1, the stack’s weight count is lower. Equal receptive fields do not mean equal functions: the intermediate ReLUs matter.

A pocket map of this sheet
IdeaWhat it changesTypical defaultWatch for
KernelWhat is detected3×3Unflipped cross-correlation in code
StrideOutput grid and jump1, or 2 to downsampleFloor leftovers
PaddingWhether borders are centresP = 1 with 3×3Framework “same” with stride 2
Feature mapsHow many detectorsDouble after a downsampleParams ignore H, W
PoolingSummary, cheap downsample2×2 max, stride 2No learned weights
Receptive fieldSupport on the inputGrows with depthTheoretical vs effective
TranslationConv equivariant, not invariant—Pooling can help; no general guarantee
AlexNetReLU, dropout, GPUs11×11 S=4 firstFC parameter hog
VGGDeep 3×3 stacksP = 1, pool halvesVery heavy FC tail
05 / TRY IT
DEPTH / FIELD OF VIEW

Same field, fewer weights.

Compare receptive-field support on the same input. Weight counts assume one channel in every layer and no biases.

YOUR EXPERIMENT

How many 3×3s.

TRY THIS

Set n = 3 and compare the highlighted regions and weight counts. At n = 1 both designs coincide.

06 / CHECK YOUR UNDERSTANDING
Try it by hand

Weights in three 3×3 vs one 7×7, one in-channel and one out-channel: vs . Two 3×3 vs one 5×5: vs . VGG same-padding P for K = 3: .

Show answer

27 vs 49, 18 vs 25, P = 1. The extra ReLUs are not in the weight count and are a further reason the stack can represent a more refined function on the same field.

10
FINAL REVIEW

Eight questions,
then three sentences.

Complete ✓
CASE FILE / FIRST LAYER

Expected 55. Got 54. What changed?

You expect 55 output positions from an 11×11 filter at stride 4. Compare a 224-pixel input with padding 0 and padding 2.

INPUT224
KERNEL / STRIDE11 / 4
PADDING2
Unfold the shape calculation

P = 0: ⌊(224 − 11)/4⌋ + 1 = 54. P = 2: ⌊(224 + 4 − 11)/4⌋ + 1 = 55. A 227-pixel input with P = 0 also gives 55. Check input size and padding together.

Multiple choice · type the letter
  1. A 5×5 kernel, stride 1, no pad, on 32×32. Hout? Type 28, 32, 27 or 16.
  2. Why share a kernel across space? (a) GPUs cannot store more weights (b) The same pattern is legal everywhere (c) It makes the network equivariant to scaling (d) It removes the need for padding.
  3. Max-pool 2×2 stride 2 is (a) a learned 2×2 kernel (b) a parameter-free downsample (c) the same as stride-2 convolution (d) translation equivariant with no qualification.
  4. Three 3×3 stride-1 layers, RF?
  5. Convolution is (a) invariant (b) equivariant (c) neither (d) only equivariant after pooling. Type the letter.
  6. VGG prefers 3×3 stacks because (a) they have a larger field than 7×7 (b) they match the field with fewer weights and more nonlinearities (c) they need no padding (d) AlexNet already used only 3×3.
  7. 16 filters, 32 input channels, 3×3, with bias. Parameters?
  8. AlexNet first-layer stride 4 mainly (a) increases parameters (b) downsamples and sets jump = 4 (c) is same-padding (d) replaces dropout.
Show answers

1: 28 = 32 − 5 + 1. 2: (b). 3: (b) — a stride-2 convolution still has learned weights. 4: 7. 5: (b) for the conv itself. 6: (b). 7: 16×32×9 + 16 = 4608 + 16 = 4624. 8: (b).

Explain in two or three sentences

After you have a sentence, open the model answers. Nothing here is auto-marked.

  1. Why does a valid 3×3 stack shrink the image, and how does VGG stop that?
  2. Why is max-pooling not a substitute for learning kernels?
  3. Why can three 3×3 layers represent a more refined function than one 7×7 on the same field?
Show model answers

1. Each valid 3×3 removes a one-pixel border (K − 1 = 2). VGG sets P = 1 so every pixel can be a centre, and uses pooling (or later, stride) when it actually wants to downsample. 2. Pooling only summarises responses that already exist. Without a kernel, there is no detector to summarise. 3. The stack composes three linear templates with ReLU between them, so the effective function on the 7×7 patch is piecewise linear and deeper, not a single inner product.

Start the checks again?

This clears the typed answers saved for this worksheet in this browser.