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?

  1. A digit image is 28 × 28 = 784 squares. Each square holds a number from 0 (blank) to 1 (dark ink), as in chapter 6.
  2. These 784 numbers are the input. 64 hidden neurons each take a weighted sum plus bias, then bend it with ReLU (chapters 16–19).
  3. 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%.
  4. It trained on MNIST's 60,000 handwritten digits: forward pass, loss, backpropagation and fixes, in minibatches (chapters 19–24).
  5. 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.
  6. Draw a hidden neuron's weights as a picture and you see stroke-like patterns. Nobody taught it these; it found them by itself.
  7. 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