Building a neural network from scratch in C++
Building the forward and training path directly makes the mechanics behind a classifier inspectable rather than magical.
Trace one prediction.
A feed-forward handwritten-digit classifier implemented from scratch in C++, reconstructed for the browser from its verified architecture.
- 098.3%
- 10.0%
- 20.5%
- 30.3%
- 40.0%
- 50.2%
- 60.0%
- 70.4%
- 80.3%
- 90.1%
What this unit learned to notice
Red weights raise the activation; navy weights suppress it. This view is derived from the separately trained reconstruction, not the lost original model.
Parse labelled MNIST rows, normalize 784 input values, learn a hidden representation, and map it to ten class scores without relying on a neural-network framework.
- 01
Read labelled CSV rows and normalized each pixel into the 0.01–1.00 range used by the source entry point.
- 02
Constructed the verified 784 → 100 → 10 feed-forward architecture.
- 03
Encoded targets at 0.99 for the correct digit and 0.01 for the remaining outputs, then trained and queried the network.
The original neural-network header and trained weights were not retained. The interactive model is a separately trained, explicitly labelled reconstruction matching the architecture visible in the C++ source.
- C++
- Linear algebra
- Backpropagation
- MNIST
- JavaScript