Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/shakil1819/pytorch-cnn-mnist-dataset-digit-classifer
Developing a Handwritten Digits Classifier using PyTorch on the MNIST dataset .Implemented pytorch, CNN, image segmentation and classification
https://github.com/shakil1819/pytorch-cnn-mnist-dataset-digit-classifer
cnn cnn-classification image mnist-handwriting-recognition pytorch segmentation
Last synced: 23 days ago
JSON representation
Developing a Handwritten Digits Classifier using PyTorch on the MNIST dataset .Implemented pytorch, CNN, image segmentation and classification
- Host: GitHub
- URL: https://github.com/shakil1819/pytorch-cnn-mnist-dataset-digit-classifer
- Owner: shakil1819
- Created: 2024-06-19T06:48:04.000Z (6 months ago)
- Default Branch: master
- Last Pushed: 2024-07-01T06:13:42.000Z (6 months ago)
- Last Synced: 2024-07-05T17:11:58.781Z (6 months ago)
- Topics: cnn, cnn-classification, image, mnist-handwriting-recognition, pytorch, segmentation
- Language: Jupyter Notebook
- Homepage:
- Size: 22.9 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
MNIST Neural Network Project
## Objective
The objective of this project is to build a neural network from scratch to evaluate the MNIST dataset. The MNIST dataset is a collection of handwritten digits and is commonly used as a benchmark for image classification tasks in machine learning. By achieving high accuracy on this dataset, the model demonstrates its ability to perform well on similar classification tasks.
## Task Description
The project involves the following steps:
1. **Dataset Loading and Preprocessing**:
- Loading the MNIST dataset using `torchvision.datasets`.
- Applying necessary transformations like converting images to tensors and normalizing them.2. **Exploratory Data Analysis**:
- Visualizing a few samples from the dataset to understand its structure and the nature of the images.3. **Building the Neural Network**:
- Designing a neural network architecture using `torch.nn` and `torch.nn.functional`.
- Initializing the model, specifying the loss function, and defining the optimizer.4. **Training the Model**:
- Training the neural network on the training dataset.
- Validating the model on the validation dataset during training.
- Recording and plotting the training and validation loss over epochs.5. **Evaluating the Model**:
- Testing the model on the test dataset to compute the final accuracy.
- Visualizing the model’s predictions against actual labels.6. **Improving the Model**:
- Tweaking hyperparameters like learning rate and training the model again for better accuracy.7. **Saving the Model**:
- Saving the trained model for future use.8. **Sanity Checks**:
- Loading the saved model and ensuring it performs as expected.
- Visualizing predictions on random samples from the test dataset.
- Generating a confusion matrix to evaluate model performance across different classes.## Tech Stacks Used
- **Python**: The primary programming language used for the project.
- **PyTorch**: Used for building and training the neural network.
- **Torchvision**: Used for loading the MNIST dataset and applying transformations.
- **Matplotlib**: For plotting loss curves and visualizing images.
- **Seaborn**: For plotting the confusion matrix.
- **Scikit-learn**: For generating the confusion matrix.## Usage
To run the project, ensure you have the necessary libraries installed. You can install the required packages using:
```bash
conda install torch torchvision matplotlib seaborn scikit-learn
```Then, execute the notebook or script to train the model and evaluate its performance on the MNIST dataset.
## Conclusion
This project provides a comprehensive workflow for building, training, and evaluating a neural network on the MNIST dataset. The final model achieves a high accuracy, demonstrating its effectiveness in classifying handwritten digits. The project also includes steps to improve the model, save it, and perform sanity checks to ensure its reliability.
![image](https://github.com/shakil1819/PyTorch-CNN-MNIST-Dataset-Digit-Classifer/assets/58840439/0b6b7924-1a33-4eef-ab15-54bcbc3ba9c2)