Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Kaggle Digit Recognizer — CNN with TensorFlow & Keras

A convolutional neural network built from scratch to classify handwritten digits (0–9), submitted to the Kaggle Digit Recognizer competition.

Competition accuracy: 98.685%


Overview

The model is trained on the MNIST-based Kaggle dataset of 28×28 grayscale images of handwritten digits. The goal is to correctly identify the digit in each image.

This project covers the full pipeline from data loading and visualization, through model architecture design and hyperparameter tuning, to generating a competition submission file.

The project has been completed in 2022.


Model Architecture

Built using the Keras Sequential API with the following layers:

Layer Details
Rescaling Normalizes pixel values to [0, 1]
Reshape Converts flat input to 2D image (28×28×1)
Conv2D × 2 Feature extraction
MaxPooling2D Spatial downsampling
Conv2D × 2 Deeper feature extraction
MaxPooling2D Further downsampling
Flatten Converts 2D feature maps to 1D vector
Dense Fully connected layer
Dropout Regularization to reduce overfitting
Dense (10 nodes) Output layer — one node per digit class
  • Total parameters: 403,938 (all trainable)
  • Loss function: Sparse Categorical Cross-Entropy
  • Optimizer: Adam
  • Callbacks: Learning rate scheduler, model checkpoint

Results

Set Accuracy
Validation (15% holdout) ~99%
Kaggle competition test set 98.685%

Project Structure

digit-recognizer-cnn/
│
├── digit_recognizer.ipynb   # Full pipeline notebook
├── requirements.txt         # Dependencies
└── README.md

Note: The dataset is not included in this repo. It can be downloaded directly via the Kaggle API as shown in the notebook.


How to Run

  1. Clone the repository:
git clone https://github.com/MostafaJahanian/digit-recognizer-cnn.git
cd digit-recognizer-cnn
  1. Install dependencies:
pip install -r requirements.txt
  1. Set up Kaggle API credentials (kaggle.json) and run the notebook top to bottom.

The notebook was developed in Google Colab. The data loading cells use the Kaggle API and Colab file upload — adjust these if running locally.


Dependencies

See requirements.txt. Main libraries: TensorFlow, Keras, Pandas, NumPy, Matplotlib, Seaborn, Scikit-learn.


Author

Mostafa Jahanian LinkedIn · GitHub

About

CNN for handwritten digit classification, 98.685% accuracy on Kaggle competition

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages