This repository contains an implementation of a handwritten digits classifier using PyTorch. The model is trained to recognize handwritten digits from the famous MNIST dataset.
The goal of this project is to build a neural network-based classifier that can accurately recognize handwritten digits from the MNIST dataset. The MNIST dataset consists of 28x28 grayscale images of hand-drawn digits from 0 to 9.
To run the code in this project, you need the following dependencies:
- Python 3
- PyTorch (>= 1.7.0)
- torchvision
- matplotlib
- numpy
-
Imports: Import the necessary libraries and modules, including PyTorch, torchvision, and matplotlib.
-
Load the dataset: Load the MNIST dataset using torchvision and create data loaders for both the train and test sets.
-
Justify your preprocessing: Explain the preprocessing steps chosen, such as
ToTensor()andNormalize(), and their importance. -
Explore the dataset: Use matplotlib and torch to explore the data dimensions and view sample images.
-
Build your neural network: Design the neural network architecture using PyTorch's
nn.Module. -
Specify a loss function and an optimizer: Define the loss function and optimizer for training the model.
-
Running your neural network: Train the model using the training data and validate it using the test data.
-
Plot the training loss: Visualize the training loss over epochs to monitor the model's training progress.
-
Testing your model: Evaluate the trained model's performance on the test set and calculate the accuracy.
-
Improving your model: Suggest potential improvements to the model, such as architecture changes or hyperparameter tuning.
-
Saving your model: Save the trained model for future use.
The trained model achieves an accuracy of approximately 97.73% on the test set. This performance can be further improved by fine-tuning hyperparameters or exploring different model architectures.
This project is licensed under the MIT License. See the LICENSE file for details.
- The model architecture and training techniques are inspired by various online tutorials and resources.
- Thanks for Udacity Team for giving me the opportunity and necessary resources to work on this project.
- Thanks to the PyTorch community for providing an excellent deep learning framework.