Author: Yash Patel
This project uses the MNIST dataset, an open-source collection of handwritten digit images (0β9).
- 60,000 training images
- 10,000 testing images
- Each image is 28 Γ 28 pixels, grayscale
- Each image is labeled with the digit it represents (0β9)
The goal of this project is to build a Convolutional Neural Network (CNN) that can recognize and classify handwritten digits with high accuracy.
- Normalization: Pixel values were scaled to the range [0,1] for faster convergence.
- One-hot encoding: Labels were converted to vectors so that the model outputs probabilities across 10 classes.
The model is a CNN, consisting of the following layers:
-
Conv2D (32 filters, 3Γ3, ReLU) Γ2
- Extracts local features (edges, corners, textures).
- ReLU introduces non-linearity.
-
MaxPooling2D (2Γ2)
- Reduces spatial dimensions, speeds up computation, and reduces overfitting.
-
Dropout (25%)
- Randomly drops neurons during training to prevent overfitting.
-
Conv2D (128 filters, 3Γ3, ReLU) Γ2
- Learns deeper, more detailed patterns.
-
MaxPooling2D (2Γ2) + Dropout (25%)
-
Conv2D (256 filters, 3Γ3, ReLU)
- Detects high-level abstract features.
-
MaxPooling2D (2Γ2) + Dropout (25%)
-
Flatten
- Converts 2D feature maps into a 1D vector.
-
Dense Layers
- 128 β 100 β 80 β 40 neurons (ReLU)
- Fully connected layers for feature combination.
-
Dense (10, Softmax)
- Outputs probabilities for digits 0β9.
- The highest probability corresponds to the predicted digit.
- Optimizer: Adam (adaptive learning rate)
- Loss Function: Categorical Cross-Entropy (multi-class classification)
- Metric: Accuracy
The model was trained for 10 epochs with a batch size of 128.
- Test Accuracy: 99.36% on the 10,000 test images
- The model demonstrates excellent performance in handwritten digit recognition.