A minimal, fully-connected feedforward neural network implemented from scratch in Python using NumPy. Supports mini-batch SGD training with backpropagation and sigmoid activations.
Inspired by Michael Nielsen’s Neural Networks and Deep Learning.
I built this to understand the full training pipeline end-to-end: forward pass → cost gradient → backpropagation → parameter updates (weights & biases), without relying on high-level frameworks.
- Flexible architecture via
sizes(e.g.[784, 64, 10]) - Sigmoid activation function
- Mini-batch Stochastic Gradient Descent
- Backpropagation for gradients of weights and biases
- Simple evaluation with
score()(classification accuracy count)
- Python
- NumPy
├── network.py # Network class + sigmoid utilities
├── train.py # Example training script (you create this)
├── data_loader.py # Optional: load/prepare dataset (you create this)
└── README.md
python -m venv .venv
# Windows:
.venv\Scripts\activate
# Linux/macOS:
source .venv/bin/activate
pip install -r requirements.txt
python test.py
Test accuracy: ~95% on the MNIST test set (10,000 images).
Model: sizes = [784, 30, 10] (sigmoid activations).
Training: epochs = 10, mini-batch size = 10, eta (learning rate) = 1.0.
Preprocessing: input pixels normalized to [0, 1], labels one-hot encoded for training
