This project is a complete implementation of a neural network for MNSIT digit recognition, built entirely from scratch without using any deep learning frameworks.
It combines Core Neural Network Maths, V****ectorized Numerical Computing, and a User Interface that enables real-time digit drawing, prediction visualization, and dataset augmentation through user feedback.
The goal of this project is to demonstrate a strong understanding of Neural Network internals, Backpropagation, and End-to-End Machine Learning System Design, rather than relying on high-level libraries.
- Fully implemented neural network using NumPy
- Manual forward and backward propagation
- Interactive training, testing, and inference workflow
- Human-in-the-loop dataset expansion
- Persistent model parameters with resume capability
Input Layer
- 784 neurons (28 × 28 pixel grayscale image)
Hidden Layer
- 64 neurons
- ReLU activation
- He initialization
Output Layer
- 10 neurons
- Softmax activation
Loss Function
- Categorical Cross-Entropy
Optimization
- Batch Gradient Descent
- No use of TensorFlow, PyTorch, Keras, or similar frameworks
- Explicit implementation of forward propagation, backpropagation, and parameter updates
- Fully vectorized operations for efficiency and numerical stability
- Configurable number of training steps and learning rate
- Automatic checkpointing of model parameters
- Resume training from saved parameters
- Overall accuracy reporting
- Per-digit accuracy analysis with visualization
- Mouse-based digit drawing on a 28 × 28 grid
- Real-time predictions with class confidence visualization
- Optional heatmap view of pixel intensity
- MNIST-style preprocessing pipeline to ensure compatibility with training data
- Users can mark predictions as correct or incorrect
- Incorrect predictions allow manual label correction
- New samples are appended directly to the dataset
- Enables continuous dataset improvement and retraining
The drawing interface applies a preprocessing pipeline designed to closely match MNIST data characteristics:
- Gaussian smoothing
- Noise thresholding
- Bounding box extraction
- Aspect-Ratio preserving resizing
- Centering within a 28 × 28 canvas
- Center-of-Mass alignment
- Normalization to the [0, 1] range
. ├── nn/ │ ├── main.py # Application entry point │ ├── menu_ui.py # Menu-Driven GUI │ ├── ui.py # Digit drawing and Interface │ ├── model.py # Neural Network implementation │ ├── train.py # Training Logic │ ├── test.py # Evaluation and Visualization │ └── data.py # Data loading and preprocessing ├── dataset/ │ ├── data.csv # Training dataset (MNIST-Style) │ └── parameters.npz # Saved Model Parameters ├── requirements.txt └── README.md
Install dependencies:
pip install -r requirements.txt
Run the application:
python main.py
The menu allows you to:
- Train the neural network
- Test model performance
- Draw digits and observe predictions