This project implements an Artificial Neural Network (ANN) for classifying handwritten digits from the MNIST dataset. The model is built using PyTorch and utilizes torchvision for dataset preprocessing.
✅ Built with PyTorch – Leverages PyTorch for efficient model building and training.
✅ MNIST Dataset – A widely used benchmark dataset for digit classification.
✅ Data Augmentation – Applies torchvision.transforms
for normalization and preprocessing.
✅ Performance Evaluation – Includes accuracy measurement and confusion matrix visualization.
To set up the environment, install the required dependencies using:
pip install torch torchvision numpy pandas matplotlib scikit-learn
The MNIST dataset is automatically downloaded via torchvision.datasets
. It consists of 60,000 training images and 10,000 test images of handwritten digits (0-9), each sized 28×28 pixels.
The ANN model follows this architecture:
Execute the following script to train the model:
python train.py
Once trained, you can evaluate its performance using:
python evaluate.py
The model performance is evaluated based on:
🎯 Training Accuracy: 98.5%
✅ Validation Accuracy: 97.8%
📌 Confusion Matrix:
[[ 0 1 2 3 4 5 6 7 8 9]]
[[ 968 0 1 0 0 1 6 1 1 1]
[ 1 1122 1 0 0 0 2 3 0 2]
[ 0 1 1010 1 3 0 2 5 6 0]
[ 1 4 9 997 0 26 1 4 11 8]
[ 1 0 2 0 966 2 8 3 5 11]
[ 1 0 0 2 1 851 5 0 2 4]
[ 1 2 0 0 3 3 926 1 1 0]
[ 1 1 2 3 2 1 0 999 2 0]
[ 5 5 7 5 1 4 8 4 943 5]
[ 1 0 0 2 6 4 0 8 3 978]]
📖 PyTorch Documentation
📖 Torchvision MNIST Dataset
📝 This project is licensed under the MIT License. Feel free to modify and use it!
© 2025 Syed Faizan. All Rights Reserved.