Skip to content

hansikadev/MNIST-Digit-Classification-using-PyTorch

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MNIST Digit Classification using PyTorch

This project implements a handwritten digit classifier using a fully connected neural network built with PyTorch.
The model is trained and evaluated on the MNIST dataset, which contains grayscale images of handwritten digits (0–9).


Project Overview

  • Task: Handwritten digit classification
  • Dataset: MNIST
  • Framework: PyTorch
  • Model: Fully Connected Neural Network
  • Output: Digit class (0–9)

Model Architecture

Input (28 × 28 = 784)
→ Linear (128) + ReLU
→ Linear (64) + ReLU
→ Linear (10)


Dataset

The MNIST dataset contains:

  • 60,000 training images
  • 10,000 test images
  • Image size: 28 × 28 (grayscale)

The dataset is automatically downloaded using torchvision.


Requirements

Install the required libraries using:

pip install torch torchvision matplotlib

Training Details

  • Loss Function: CrossEntropyLoss
  • Optimizer: Adam
  • Learning Rate: 0.001
  • Epochs: 5

Results

The model achieves approximately 97% accuracy on the MNIST test dataset after training.

A sample image is displayed along with:

  • Actual label
  • Predicted label

Model Saving

After training, the model is saved as:

mnist_model.pth

Future Improvements

  • Use a Convolutional Neural Network (CNN)
  • Add validation accuracy plots
  • Support custom image input

About

This project implements a handwritten digit classification model using PyTorch. A fully connected neural network is trained on the MNIST dataset to recognize digits from 0 to 9. The model preprocesses 28×28 grayscale images, learns discriminative features through dense layers, and achieves high accuracy on the test dataset.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors