A feed-forward neural network built entirely from scratch using NumPy — no TensorFlow or PyTorch for training
This project implements a complete neural network from scratch using only NumPy, trained on the MNIST handwritten digits dataset. It demonstrates how fundamental deep learning components — forward propagation, backpropagation, activation functions, dropout, and optimizers — work under the hood.
Achieves 90%+ accuracy on MNIST test data with simple hyperparameters.
- Forward and Backward Propagation
- Sigmoid and ReLU activation functions
- Softmax output layer
- Cross-Entropy loss function
- Dropout regularization
- SGD and Momentum optimizers
- Training progress visualization
- Data Loading & Preprocessing — Loads MNIST from Keras, normalizes pixel values, one-hot encodes labels
- Network Construction — Custom
NeuralNetworkclass with configurable hidden layers, activations, and dropout - Training — Batch training with SGD or Momentum optimizer, logging loss and accuracy per epoch
- Visualization — Plots training loss and accuracy curves using Matplotlib
Typical output after ~200 epochs:
Epoch 200: Loss = 0.2435, Train Acc = 0.9365, Test Acc = 0.9268
numpy
matplotlib
keras
tensorflow
pip install numpy matplotlib keras tensorflowpython Code.pyPrints epoch-by-epoch loss and accuracy, then displays training curves in a Matplotlib window.
- Built a functional neural network entirely from scratch using NumPy
- Learned how optimizers, dropout, and activations affect performance
- Gained deeper understanding of gradient flow and convergence
MIT License — feel free to use, modify, and share with attribution.
- MNIST dataset by Yann LeCun
- Keras for dataset loading utilities