ylecun/mnist
Viewer β’ Updated β’ 70k β’ 68.6k β’ 302
A fully-connected network built with only NumPy: hand-derived backpropagation and mini-batch SGD, no deep-learning framework. It reaches 97.83% test accuracy on MNIST and trains in about 88 seconds on a Colab CPU.
784 β 128 β 64 β 32 β 10 (four weight layers, 111,146 parameters)NeuralNetwork class with forward, backward, step and fit; backprop verified against numerical gradients before trainingLearning and demonstration: seeing exactly how forward propagation, backpropagation and SGD work, without framework abstractions. Not intended for production use.
| Data | MNIST (90% train / 10% validation split of the training set, official test set held out) |
| Preprocessing | pixels scaled to [0, 1], flattened to 784 |
| Optimiser | mini-batch SGD, batch size 128 |
| Learning rate | 0.1 with Γ0.95 decay per epoch |
| Regularisation | L2, Ξ» = 1e-4 |
| Epochs | 30 (default notebook config) |
| Hardware | Colab CPU |
| Metric | Value |
|---|---|
| Test accuracy | 97.83% |
| Test loss | 0.0824 |
| Training time | 88.2 s (Colab CPU) |
net = load_weights("nn_weights.npz") # helper defined in the notebook
pred = net.predict(X_test[:5])
Code and weights: MIT. MNIST is by LeCun, Cortes and Burges.