Skip to content

todor02/MNIST_CNN

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MNIST CNN 🧠

A simple Convolutional Neural Network built in TensorFlow to classify handwritten digits from the MNIST dataset.

  • main branch → runs on CPU
  • cuda branch → runs on GPU

CUDA Branch Only:

You must have CUDA and cuDNN installed manually (not included in requirements.txt).

If you have an older GPU, you may encounter TensorFlow bugs. In that case, try:

pip install tensorflow==2.10.0

🚀 Overview

This project demonstrates how to construct, train, and evaluate a CNN for recognizing digits (0–9) in grayscale 28×28 pixel images. The MNIST dataset is one of the foundational benchmarks in deep learning and computer vision.


✍️ Interactive GUI

In addition to training and evaluating the model, the project includes an interactive GUI where you can draw digits and have them recognized by the trained CNN.


🧱 Model Architecture

The network typically consists of:

  • Conv2D layer → ReLU activation
  • MaxPooling2D layer
  • (Repeated stack of Conv + Pool)
  • FlattenDenseSoftmax output for 10 classes

This setup achieves robust performance (often 98–99% accuracy on test set) :contentReference[oaicite:0]{index=0}.


🛠️ How to Use

Requirements

pip install tensorflow numpy matplotlib

Training & Evaluation

python main.py

This will:

  1. Download and preprocess MNIST dataset

  2. Train the CNN model

  3. Evaluate test accuracy and print results


📊 Results

Sample output when evaluation completes:

Test Accuracy: 0.99

(Actual numbers depend on training parameters, epochs, and TensorFlow version.)


📝 Optional Enhancements

You might consider extending this project with:

  • Data augmentation (rotations, shifts)

  • Additional Conv + Dense layers for deeper architectures

  • Early stopping or checkpoint saving

  • Visualizing training history using matplotlib

  • Porting to TensorFlow 2.x + Keras or PyTorch

  • Deploying as a web API or mobile app

📚 Learn More

Deep dive tutorial:

About

Building a CNN with MNIST dataset. Using tensorflow, and achieving 99% accuracy!

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages