E ExamMaster

Deep Learning · Deep Learning

CNNs on Tiny Images

In Deep Learning because convolutions exploit spatial structure — a neural, not tabular, inductive bias.

Convolutions share weights across local patches.

  • Deep Learning
  • Medium level
  • 3 concepts

1Why convolution

Nearby pixels interact; a shared filter detects the same pattern everywhere.

Parameter count stays lower than a giant dense layer on flattened pixels.

Animation: a 6 by 6 input grid whose right half is shaded, forming one vertical edge, beside an empty 4 by 4 feature map. A gold 3 by 3 filter outline slides across the input; at each stop an arrow fills the matching feature-map cell with the computed response. When the sweep finishes, the two feature-map columns that straddle the edge glow gold while the rest stay dark, captioned bright cells equal the edge found in every row, and shared weights mean far fewer parameters than dense
One small filter reuses the same 9 weights at every position, so the same pattern - here a vertical edge - is detected wherever it appears, at a fraction of the parameters a dense layer on flattened pixels would need.
A dense layer on flattened pixels must learn 'edge in the top-left' and 'edge in the bottom-right' as two separate things. What does a convolution change?
  1. It shrinks the image before the layer ever sees it
  2. One set of filter weights is applied at every position, so the pattern is learned once and can then be found anywhere
  3. It removes the need for an activation between layers
  4. It learns a separate filter for each pixel, which is more precise

Weight sharing is both the parameter saving and the inductive bias. It encodes the assumption that a pattern means the same thing wherever in the image it turns up.

2Tiny stacks

Conv → ReLU → pool patterns extract edges then parts.

For labs, use 8×8 or 16×16 synthetic grids — not ImageNet.

Figure. A tiny stack is conv, then ReLU, then pool: edges first, then parts. Teaching labs stay on 8×8 or 16×16 synthetic grids, not ImageNet.

Why do the later layers of a convolutional stack respond to parts rather than to edges?
  1. Later layers use larger filters by definition
  2. Each layer sees a wider patch of the original image through the layers beneath it, so it can combine their edges into something larger
  3. Pooling substitutes parts for edges directly
  4. The edges are discarded after the first ReLU

The filters stay small; what grows is how much of the input each position can see. That widening view is what lets a stack build edges into corners and corners into parts.

3Lab: tensorflow dense on grids

Flatten tiny grids and fit a small Sequential model — a stepping stone before true conv layers.

Print a score loss after a few epochs on synthetic data.

Figure. The stepping-stone lab flattens 200 rows of 8 features through Dense 16 ReLU, then Dense 1 sigmoid, fits 5 epochs, and prints a score. It is a Sequential dress rehearsal before true conv layers.

Coding lab. Tiny tf Sequential runs in the app, with checks on your output.

This lab flattens the grid and uses Dense layers. What does flattening throw away?
  1. The pixel values, which are replaced by their positional indices
  2. The labels, which have to be reattached afterwards
  3. Which pixels were neighbours — the very structure a convolution exists to exploit
  4. Nothing at all, since a reshape preserves every number

Every number does survive the reshape, which is what makes this trap comfortable. What is lost is adjacency: to a dense layer, two neighbouring pixels are no more related than two opposite corners.

Notes

  • Convolutional filters for small grids — browser-safe sizes only.
  • Nearby pixels interact; a shared filter detects the same pattern everywhere.
  • Conv → ReLU → pool patterns extract edges then parts.

Exam traps & shortcuts

  • Keep lab datasets under 2000 rows in the browser runtime.
  • Split train and test before fitting any model that sees labels.

Recap

This lesson in brief:

Why convolution
Nearby pixels interact; a shared filter detects the same pattern everywhere.
Tiny stacks
Conv → ReLU → pool patterns extract edges then parts.
Lab: tensorflow dense on grids
Flatten tiny grids and fit a small Sequential model — a stepping stone before true conv layers.

Practise CNNs on Tiny Images

Reading is free and needs no account. Practice, mocks and progress live in the app.

  • A 1-question practice set that ends the chapter
  • 3 quick checks with worked explanations
  • Timed mocks scored with the real marking scheme
  • Readiness tracked per topic, kept on your device
Continue with Google — freeNo card, no trial. Works offline once installed.