This project implements a feedforward neural network (Multilayer Perceptron) using TensorFlow/Keras to classify handwritten digits from the MNIST dataset. The notebook demonstrates a complete deep learning workflow, including data loading, preprocessing, model design, training, and evaluation.
The model learns to classify grayscale images of handwritten digits (0–9) with high accuracy.
MNIST Handwritten Digits Dataset
- 60,000 training images
- 10,000 test images
- Image resolution: 28 × 28 pixels
- Grayscale images
- Classes: digits 0 to 9
The dataset is loaded directly using Keras:
from tensorflow import keras
(X_train, y_train), (X_test, y_test) = keras.datasets.mnist.load_data()- Images are normalized to the range
[0, 1]. - Flattened into 1D vectors to feed into the fully connected layers.
- Dataset is split into training and test sets.
The model is a fully connected feedforward neural network (MLP).
| Layer | Type | Units | Activation | Purpose |
|---|---|---|---|---|
| Input | Flatten | 784 | – | Converts 2D image to 1D vector |
| Hidden Layer 1 | Dense | 128 | ReLU | Learns high-level features |
| Hidden Layer 2 | Dense | 64 | ReLU | Feature refinement |
| Output Layer | Dense | 10 | Softmax | Class probability distribution |
After training, the model is evaluated on the unseen test dataset.
Test Accuracy: ~ 97–98%