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
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.0This 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.
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.
The network typically consists of:
- Conv2D layer → ReLU activation
- MaxPooling2D layer
- (Repeated stack of Conv + Pool)
- Flatten → Dense → Softmax output for 10 classes
This setup achieves robust performance (often 98–99% accuracy on test set) :contentReference[oaicite:0]{index=0}.
pip install tensorflow numpy matplotlibpython main.py-
Download and preprocess MNIST dataset
-
Train the CNN model
-
Evaluate test accuracy and print results
Sample output when evaluation completes:
Test Accuracy: 0.99(Actual numbers depend on training parameters, epochs, and TensorFlow version.)
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
Deep dive tutorial: