AI Anatomy Class · Part 2 · How machines learn
26. Hands-on: handwritten digits
Q. Can a neural network really read a digit you write with your finger?
- A digit image is 28 × 28 = 784 squares. Each square holds a number from 0 (blank) to 1 (dark ink), as in chapter 6.
- These 784 numbers are the input. 64 hidden neurons each take a weighted sum plus bias, then bend it with ReLU (chapters 16–19).
- 10 output neurons give scores for 0–9, and softmax turns them into probabilities (chapter 14). Here: 3 is 87.5%, 5 is 11.3%.
- It trained on MNIST's 60,000 handwritten digits: forward pass, loss, backpropagation and fixes, in minibatches (chapters 19–24).
- After training, it was graded on 10,000 test images it had never seen and got 97.96% right. It's the very network inside this app.
- Draw a hidden neuron's weights as a picture and you see stroke-like patterns. Nobody taught it these; it found them by itself.
- Now it's your turn. Draw a digit with your finger in the box below, and the network in your browser reads it right away.
Chapter summary
- A digit image = 28 × 28 = 784 numbers. That's the network's input.
- 784 → 64 hidden neurons (ReLU) → 10 outputs → softmax gives probabilities for 0–9.
- Trained on MNIST's 60,000 images, it got about 98% of 10,000 new ones right.