This project explores two different approaches to solving the classic MNIST handwritten digit classification problem using PyTorch. The goal was to compare a spatially-aware model (CNN) against a sequence-aware model (RNN/LSTM) to see how they perform on the same dataset.
- Dual Architectures: Implemented a 3-layer Convolutional Neural Network and a 2-layer LSTM-based Recurrent Neural Network.
- Data Pipeline: Used
torchvisionfor normalization and data augmentation. - GPU Acceleration: Utilized CUDA for efficient training on a T4 GPU.
- Performance Tracking: Monitored training loss across 10 epochs for both models.
| Model | Test Accuracy | Final Training Loss |
|---|---|---|
| CNN | 98.79% | 0.0103 |
| RNN (LSTM) | 98.78% | 0.0189 |
- Language: Python
- Framework: PyTorch (
torch,nn,optim) - Visualization: Matplotlib
- Environment: Google Colab / GPU T4
The CNN utilizes three convolutional layers with increasing filters (32, 64, 128) and MaxPool layers to extract spatial features from the 28x28 images.
The LSTM treats each image as a sequence of 28 rows, where each row contains 28 features. This approach treats image recognition as a temporal sequence problem.
This project was developed as part of the Prime AI/ML batch program.