Introduction
This is a small project about building and training a neural network for MNIST from scratch. The goal was not to beat an established machine-learning library, but to understand what happens beneath one by implementing the essential pieces myself.
MNIST is a collection of small images of handwritten digits. It is a simple enough problem to explore without hiding the details: every pixel becomes an input, and every prediction comes from matrix multiplications and activation functions implemented directly in this project.
Try the model
Draw a digit in the grid below to run the trained network in your browser. The bars show the probability assigned to each digit, and the most likely digit is highlighted beneath the chart.
What do you see?
Click and drag across the pixels to draw. The network reads the canvas continuously.
—
A 784 → 256 → 10 multilayer perceptron.
How it works
Each 28 × 28 grayscale image is flattened into 784 numbers and passed through a hidden layer of 256 neurons. A ReLU activation keeps the positive signals, after which a final layer produces one score for each digit from 0 to 9.
The network is deliberately small. It is large enough to learn the shapes in MNIST while keeping the forward pass, gradients, weight updates, and training loop understandable. The interactive demo above uses the resulting weights directly in the browser.
The complete implementation is available on GitHub.
Training
The plot below follows the training loss and success rate as the network learns. The loss falls while the share of correctly classified digits rises, making the progress of the model visible over the course of training.
Training this implementation takes 8 hours and 40 minutes per epoch. The same task in PyTorch takes only 2.93 seconds per epoch, making my system roughly 10,000 times slower. That gap is part of the point: this is a learning project rather than an optimized framework, and I developed it entirely from scratch with NO AI assistance.