TwiddleLab / Artificial Intelligence / How Machines See and Hear
Filters Learn Themselves
What you will learn
- In a real network nobody writes the filters. They start as random numbers and training adjusts them: learned filters.
- Many learned filters end up looking like the edge filters people design.
- A person still chooses the hyperparameters: filter size, how many filters, learning rate, epochs.
- A 3 × 3 filter on a color picture has 3 × 3 × 3 = 27 weights, so 16 of them have 432.
How the lesson goes
You designed an edge filter by hand. Real vision models have thousands. Who designs those?
Here are the 8 filters of a digit reader before training. Tap any that look like an edge finder, then Check.
Train it. Drag through 30 epochs of a real recorded run.
One epoch is one pass over 1,400 handwritten digits.
Did training reinvent your filters? Put each hand-made filter on its closest learned twin.
Drag a card onto a learned filter, then Check.
Edges are the cheapest clue for telling strokes apart, so training pushes some filters toward edge finders. Nobody asked for them: they appear because they lower the error.
Two kinds of numbers.
Tap to reveal.
Filters whose numbers come from training are learned filters: gradient descent nudges them like any weight.
Choices made by a person before training, like filter size, number of filters and learning rate, are hyperparameters.
When should you stop training? Put the marker where the test error stops falling.
Blue: error on the training digits. Orange: error on test digits it never learned from.
The test error tells you how the model does on new digits. Once it stops falling, extra epochs only fit the training digits better. How many epochs to run is a hyperparameter.
Game: smallest model. Reach 90% on the test digits with the fewest filters.
Choose the hyperparameters and press Train. Each run is a real recorded training.
Math: a layer has 16 filters of 3 × 3, on a color picture (3 numbers per pixel). How many weights in its filters?
Each filter has one weight for every number it looks at: 3 × 3 pixels × 3 colors = 27. Sixteen filters: 16 × 27 = 432 (plus one bias each, which we leave out here).
Here is the digit reader. Tap every part that training finds by itself.
Then Check.
Training adjusts weights: the numbers inside the filters and the output weights. The filter size, number of filters, pooling, learning rate and epochs are set before training: hyperparameters.
Duel: learned filters against hand-made ones.
Compare test accuracy for 1, 2, 4 and 8 filters.
Previous lesson: Pooling: Zooming Out · Next lesson: Reading Digits · Part of the course: How Machines See and Hear
Lessons are interactive and need JavaScript. Turn it on to play them.