Skip to content

Implementation of a Convolutional Neural Network (CNN) to classify handwritten digits using the MNIST dataset.

License

Notifications You must be signed in to change notification settings

eko-071/digit-recognition

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Handwritten Digit Recognition

Implementation of a Convolutional Neural Network (CNN) to classify handwritten digits using the MNIST dataset.

Project Structure

.
├── digit.png
├── LICENSE
├── model.keras
├── predict.py
├── README.md
├── requirements.txt
├── statistics
│   ├── diagnostics.png
│   └── summary.png
└── train.py

Usage

  1. Clone the repository and cd into it
git clone https://github.com/eko-071/digit-recognition.git
cd digit-recognition/
  1. Save the image being classified in the folder as digit.png.

Note: Input images should be grayscale with a black background and a white digit, similar to MNIST

  1. Install required packages
pip install -r requirements.txt
  1. Run the script
python predict.py

Training the Model

To train the model from scratch and generate evaluation plots:

python train.py

The script:

  • Trains a CNN on the MNIST dataset
  • Uses 5-fold cross-validation
  • Saves training statistics in statistics/
  • Saves the trained model as model.keras

Results

  • Achieves ~99% accuracy on the MNIST dataset.
  • diagnostics.png shows two plots: cross-entropy loss vs. epochs (top) and classification accuracy vs. epochs (bottom), with training and validation curves for each cross-validation fold.
  • summary.png shows a box plot of classification accuracy values obtained from all cross-validation folds.

Note: Training data is blue, and testing data is orange.

Requirements

  • numpy
  • matplotlib
  • tensorflow
  • scikit-learn

References

About

Implementation of a Convolutional Neural Network (CNN) to classify handwritten digits using the MNIST dataset.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages