A neural network built from scratch using only NumPy — no PyTorch, no TensorFlow, no autograd. Based on the Neural Networks from Scratch book by Harrison Kinsley, extended with an interactive Flask web GUI for live visualization.
Core network — neuron_test.py
Full forward pass pipeline built by hand:
- Dense (fully connected) layers
- ReLU activation
- Softmax activation with numerical stability (subtracts row max before exp to prevent overflow)
- Categorical cross-entropy loss — handles both sparse integer labels and one-hot encoded labels
Interactive GUI — neural_network_gui.py
Flask web app wrapping the network with 4 live visualizations:
- Original spiral data
- Network predictions vs ground truth
- Per-class prediction confidence heatmap
- Per-sample loss curve
Custom data generator — spiral_data.py
Hand-written n-class spiral dataset generator with configurable noise.
pip install numpy nnfs flask matplotlibRun the core network:
python neuron_test.pyLaunch the web GUI:
python neural_network_gui.pyOpen http://localhost:5000, set the number of samples and classes, and hit Train.
| Component | Details |
|---|---|
Layer_Dense |
Weight init 0.01 * randn, bias init zeros, forward via dot product |
Activation_ReLU |
Elementwise max(0, x) |
Activation_Softmax |
Numerically stable — row-max subtraction before exp |
Loss_CategoricalCrossentropy |
Clipped predictions, handles sparse and one-hot targets |
| Spiral generator | Parameterized by points and classes, Gaussian noise on angle |
Python · NumPy · Flask · Matplotlib