A clean TensorFlow/Keras dense neural network that achieves high accuracy classifying handwritten digits from the MNIST dataset — with full training visualization and single-image prediction.
This project trains a fully connected (dense) neural network on the classic MNIST dataset of 70,000 handwritten digit images. It covers the full supervised learning workflow: data loading, normalization, model building, training with validation monitoring, evaluation, and prediction.
A great first real-world deep learning implementation after understanding raw gradient descent.
| Metric | Value |
|---|---|
| Dataset | MNIST (60K train / 10K test) |
| Model Type | Dense Neural Network (MLP) |
| Input Shape | 28×28 grayscale → flattened |
| Output Classes | 10 (digits 0–9) |
| Optimizer | Adam |
| Loss Function | Categorical Crossentropy |
| Concept | Implementation |
|---|---|
| Dataset loading | tf.keras.datasets.mnist |
| Preprocessing | Pixel normalization (÷255), one-hot encoding |
| Model architecture | Flatten → Dense(128, ReLU) → Dense(10, Softmax) |
| Training | Validation split, accuracy tracking |
| Evaluation | Test set loss and accuracy |
| Visualization | Training & validation curve plots |
| Prediction | Single test-image inference |
Flatten(28 × 28)
↓
Dense(128, ReLU)
↓
Dense(10, Softmax)
| Tool | Purpose |
|---|---|
| Python 3.x | Core language |
| TensorFlow / Keras | Model building and training |
| NumPy | Data manipulation |
| Matplotlib | Training curve visualization |
git clone https://github.com/sainathac/mnist-digit-classifier.git
cd mnist-digit-classifierpip install -r requirements.txtpython src/main.pyThis is Lab 2 of 6 in a TensorFlow/Keras deep learning learning series:
- Neural Network From Scratch
- MNIST Digit Classifier ← You are here
- Fashion-MNIST Model Lifecycle
- Cats vs Dogs CNN Classifier
- VGG16 Transfer Learning Classifier
- IMDB Sentiment RNN
Sainatha C AI Automation & RPA Engineer | Data Science Practitioner