This project walks through building image classification models from scratch using PyTorch, starting from a simple linear classifier and progressing to deep multilayer neural networks. This project implements neural networks from scratch using PyTorch, starting from a simple linear classifier and progressively building deeper neural networks for image classification on the MNIST dataset.
The goal of this project is to understand the mathematical and implementation details behind modern deep learning models without relying on high-level abstractions.
- Linear models
- Cross entropy loss
- Gradient descent
- Stochastic Gradient Descent (SGD)
- Mini-batch training
- Custom DataLoader
- Weight initialization
- ReLU activation
- Two-layer neural networks
- Deep multi-layer neural networks
- MNIST image classification
- SuperML.ipynb
- README.md
The notebook follows the progression below:
- Download MNIST using
torchvision - Visualize handwritten digit images
- Understand image dimensions and labels
- Flatten images from
28 × 28→784 - Normalize pixel values between
0and1 - Prepare train and test datasets
Implements a linear classifier:
Topics covered:
- Weight initialization
- Forward propagation
- Logits
- Prediction
Implements cross entropy loss from scratch:
Topics covered:
- Softmax intuition
- Loss computation
- Classification objectives
Implements Stochastic Gradient Descent manually:
Topics covered:
- Gradient computation
- Backpropagation
- Learning rate
- Parameter updates
Builds a sequential mini-batch DataLoader:
- Batch iteration
- Efficient training loops
- Mini-batch optimization
Train the classifier on MNIST:
- Training loop
- Loss tracking
- Error computation
- Evaluation on test set
Extends the model using:
Topics covered:
- Hidden layers
- ReLU activation
- Nonlinear learning
Implements deeper neural networks using arbitrary hidden layers:
Topics covered:
- Deep learning intuition
- Multi-layer architectures
- Improved representation learning
The project visualizes:
- Training loss
- Test loss
- Classification error
- Model predictions
This demonstrates how deeper neural networks significantly outperform simple linear models on image classification tasks.
This project is designed to build intuition for:
- How neural networks work internally
- How backpropagation updates parameters
- Why nonlinear activations matter
- How deep learning models learn patterns from data
A single linear layer can only learn linear decision boundaries.
Adding hidden layers and nonlinear activations allows neural networks to learn complex patterns and significantly improve classification performance.
