Experience Digit Recognition from the Neural Network Perspective
A small convolutional network, 99% accurate on MNIST, running live in your browser. Weights: ONNX Model Zoo (MIT).
What is a neural network?
You've probably heard of AI: computers doing things that seem smart. Most of today's AI is machine learning, where a computer learns from examples instead of following rules a person wrote. Your spam filter learned what spam looks like from millions of emails. Your phone learned to find "dog" in your photos from millions of labelled pictures.
A neural network is the most popular kind of machine learning. It is loosely inspired by the brain: many simple parts, linked in layers, each passing a signal to the next. On its own, each part does almost nothing. Together, they can recognise faces, voices and, here, handwriting.
How did it learn?
Nobody told this network what a 3 looks like. It was shown tens of thousands of handwritten digits, each with the right answer. At first it guessed at random. After every wrong guess it adjusted itself a tiny bit, and after enough examples it got about 99 out of 100 right. That learning is finished; the network on this page just uses what it learned.
What you're watching
Follow the demo from the bottom up.
- You draw: your digit.
- Network sees: the same digit, shrunk to a small grid, the way the network learned to see digits.
- Layer 1: eight small detectors scan the grid. Each looks for one kind of stroke: a line, an edge, a curve. The coloured patch shows what it looks for (green wants ink, magenta wants blank paper). The darker the square above, the more of that stroke it found.
- Layer 2: sixteen more detectors look at what layer 1 found and spot bigger shapes: a loop, a corner, a crossing.
- Top row: one box for each digit, 0 to 9. The fuller the box, the surer the network is. The green outline marks its answer.
Why "convolutional"?
It's the name for networks that use these scanning detectors. The same detector slides across the whole picture, so a stroke counts wherever you draw it. That's the same idea that lets a phone find a face anywhere in a photo.
Try this
- Click any square or patch to see it larger.
- Draw a 4 slowly and watch the answer change as you add strokes.
- Draw a letter or a cat. The network only knows digits, so it will still confidently name one, which shows that it doesn't "understand" anything, it only matches patterns.
Want more?
- But what is a neural network? by 3Blue1Brown: the best-known 20-minute introduction, using this same digit example.
- CNN Explainer from Georgia Tech: an interactive look inside a bigger convolutional network.