Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

README.md

🧠 MNIST Digit Classification with Artificial Neural Network (ANN)

This project builds an Artificial Neural Network (ANN) using TensorFlow/Keras to classify handwritten digits from the MNIST dataset. An ANN is the simplest form of deep learning — layers of interconnected neurons that learn patterns from data.


📁 Dataset Overview

The MNIST dataset contains 70,000 grayscale images of handwritten digits (0-9):

  • Training set: 60,000 images
  • Test set: 10,000 images
  • Each image is 28x28 pixels (784 features when flattened)
  • 10 classes: digits 0 through 9

🎯 Objective

To build a simple feedforward neural network that learns to recognize handwritten digits from pixel values alone, demonstrating the core concepts of deep learning — layers, activation functions, and backpropagation.


🧠 Why ANN?

  • ANNs are the foundation of deep learning — understanding them is essential before CNNs or RNNs
  • A simple 2-3 layer network can achieve >97% accuracy on MNIST
  • ANN introduces key concepts: forward propagation, loss functions, optimization, and epochs
  • Starting simple makes the jump to CNNs more understandable

🧪 Tools & Libraries Used

  • Python
  • Jupyter Notebook
  • pandas, numpy for data handling
  • matplotlib, seaborn for visualization
  • tensorflow / keras for building and training the neural network

📊 Model Architecture

  • Input Layer: 784 neurons (28x28 flattened)
  • Hidden Layer 1: 128 neurons, ReLU activation
  • Dropout: 20% for regularization
  • Hidden Layer 2: 64 neurons, ReLU activation
  • Output Layer: 10 neurons, Softmax activation

Total parameters: ~110,000


📊 Process Overview

  1. Data Loading & Exploration:

    • Loaded MNIST from tf.keras.datasets
    • Visualized sample digits
    • Checked class distribution
  2. Data Preprocessing:

    • Normalized pixel values to [0, 1] range
    • One-hot encoded labels for multi-class classification
    • Flattened 28x28 images to 784-length vectors
  3. Modeling:

    • Built a Sequential model with Dense layers
    • Used categorical crossentropy loss and Adam optimizer
    • Trained for 10 epochs with validation split
  4. Evaluation & Visualization:

    • Evaluated on test set
    • Plotted training/validation accuracy and loss curves
    • Visualized sample predictions

📌 Key Results

  • The ANN achieved >97% accuracy on test data after 10 epochs
  • Training and validation accuracy converged smoothly — minimal overfitting
  • Most misclassifications occurred between visually similar digits (4 vs 9, 3 vs 8)
  • Dropout regularization helped prevent overfitting

📂 Folder Structure

ML-DL-Projects/
├── Deep-Learning/
│   └── ANN/
│       ├── dataset/           # (MNIST loaded via tf.keras, no CSV)
│       ├── images/
│       │   ├── training_history.png
│       │   └── sample_predictions.png
│       ├── notebooks/
│       │   └── ANN_Example.ipynb
│       └── README.md
├── uv.lock
├── pyproject.toml

🚀 Getting Started

To run this project locally:

Step 1: Set up environment

cd ML-DL-Projects
uv sync

Step 2: Run notebook

jupyter notebook

Then open ANN_Example.ipynb.


💡 Future Ideas

  • Add more hidden layers or increase neurons and see how accuracy changes
  • Experiment with different activation functions (tanh, leaky ReLU)
  • Try different optimizers (SGD, RMSprop) and compare convergence
  • Compare ANN performance directly with CNN on the same dataset

📬 Contact

Feel free to reach out if you have questions or want to collaborate!