Handwritten digit recogniser (CNN)
Train a CNN to read handwritten digits at 99% accuracy, then draw your own digits in a web canvas to test it.
Beginnerโฑ 6โ10 hours๐ช 7 stepsPythonPyTorch or TensorFlow/KerasMNIST
What you'll learn
- โConvolutional neural networks
- โTraining loops, loss and accuracy curves
- โOverfitting and dropout
What you'll build
- โCNN trained on MNIST
- โTraining and validation curves
- โConfusion matrix of mistakes
- โDraw-a-digit demo
Step-by-step guide
- 1
Load MNIST
torchvision.datasets.MNIST (or keras.datasets.mnist); normalise pixels to 0โ1.
- 2
Baseline
Start with a simple dense network to see ~97% accuracy.
- 3
CNN
Two Conv2d + ReLU + MaxPool blocks, then Dropout and a Linear layer to 10 classes.
- 4
Train
Adam optimiser, cross-entropy loss, 5โ10 epochs; plot train vs validation accuracy.
- 5
Inspect errors
Show the misclassified test images; most are genuinely ambiguous.
- 6
Save
torch.save(model.state_dict()) or model.save("mnist.keras").
- 7
Demo
A Streamlit app with a drawable canvas (streamlit-drawable-canvas); resize to 28ร28, invert colours to match MNIST, predict.
๐ Make it stand out
- +Data augmentation
- +Train on Devanagari digits
- +Export to ONNX and run in the browser