neuralnet-from-scratch
Draw a digit from 0 to 9.
network sees
Draw in the box to see the network’s guess.
Neural network guess.
How it works
A 784 → 16 → 16 → 10 network with ReLU hidden layers and a softmax output, trained with plain SGD (learning rate 0.1, batches of 100, 10 epochs) on the 60,000 MNIST training digits. Your drawing is cropped, scaled and centred.
| Implementation | Test accuracy |
|---|---|
| NumPy, from scratch | 95.00 ± 0.27% |
| PyTorch, same network | 95.07 ± 0.31% |
How it works
A wider 784 → 128 → 128 → 47 network trained on EMNIST Balanced: 112,800 handwritten digits and letters. Lowercase letters that look like their capitals (c, o, s, x and others) share a class with them, which leaves 47 classes. Your drawing is cropped, scaled and centred.
| Optimiser | From scratch | torch.optim |
|---|---|---|
| SGD, learning rate 0.1 | 82.91 ± 0.30% | 82.99 ± 0.29% |
| SGD with momentum 0.9, learning rate 0.01 | 82.89 ± 0.34% | 82.90 ± 0.30% |
| AdamW, learning rate 0.001 | 83.33 ± 0.24% | 83.34 ± 0.19% |
Each from-scratch optimiser matches its PyTorch counterpart within run-to-run variation. Some characters are ambiguous even to people, such as 0 and O, or 1, I and l, so expect the probability to be split between them.