MNIST Digit Recognition — Neural Network from Scratch

Java
JavaScript
HTML
CSS

A feed-forward neural network for handwritten digit classification, written from scratch in pure Java (no ML frameworks), paired with a responsive web playground that lets you sketch a digit and see live top-5 predictions.

The end-to-end pipeline is live online — sketch a digit, watch the network classify it: luisapr1.github.io/Digit-Recognition-NN-V2.

Network architecture

Input  : 784 neurons (flattened 28×28)
Hidden : 256 neurons, ReLU
Hidden : 128 neurons, ReLU
Output : 10 logits + Softmax

What I built

Pure-Java training backend

No PyTorch, no TensorFlow, no NumPy — just double[][]. I implemented:

Responsive web playground

A clean HTML/CSS/JS frontend that mirrors the Java preprocessing pipeline pixel-perfectly:

Why this approach

Building a neural network from scratch — instead of calling model.fit() — forces you to actually understand the math. Every class in the code corresponds to a concept on paper: Layer, Neuron, ActivationType, the analytic derivative of ReLU, the combined Softmax + Cross-Entropy gradient. Re-implementing the exact same preprocessing pipeline in JavaScript so the browser can run inference on the Java-trained weights was a satisfying systems-level constraint to satisfy.