---
title: "Neural Network from Scratch"
url: "https://ridwaanhall.com/projects/neural-network-from-scratch"
markdown: "https://ridwaanhall.com/projects/neural-network-from-scratch.md"
summary: "A professional implementation of a neural network using only NumPy for MNIST digit classification."
---

# Neural Network from Scratch

> A professional implementation of a neural network using only NumPy for MNIST digit classification.

- Category: Machine Learning
- Status: Completed
- Started: June 4, 2025
- Built with: Matplotlib, Python, NumPy, PyTorch
- Source: https://github.com/ridwaanhall/Neural-Network-from-Scratch

## About

### The problem

Frameworks like TensorFlow and PyTorch make neural networks easy to use but hide how they work, so many learners never see the mathematics behind backpropagation and optimisation.

### The approach

I implemented a complete neural network in NumPy alone, with a modular object-oriented design that makes every component swappable and inspectable.

- Six activation functions, five loss functions and four weight initialisation methods.
- SGD with momentum, learning-rate scheduling and early stopping, controlled by more than 20 CLI parameters.
- A drawing interface for live predictions, plus reports with accuracy curves, loss graphs and confusion matrices.

### The result

The network reaches 98.06% test accuracy on MNIST, competitive with framework-based baselines, and serves as both a learning tool and a base for custom experiments.

## Features

- **Pure NumPy Implementation**: No TensorFlow or PyTorch, just optimized NumPy operations.
- **High Accuracy**: Achieves 98.06% test accuracy on MNIST dataset.
- **Comprehensive CLI**: 20+ configurable parameters for training and optimization.

## Tags

Handwritten Digit Recognition, Mnist Classification, Neural Network, numpy

## Elsewhere

- This page for people: https://ridwaanhall.com/projects/neural-network-from-scratch
- Index of every page as Markdown: [llms.txt](https://ridwaanhall.com/llms.txt)
