Skip to content

Latest commit

Β 

History

History
60 lines (48 loc) Β· 2.2 KB

File metadata and controls

60 lines (48 loc) Β· 2.2 KB

πŸš€ Autoencoder for MNIST Digit Recognition

πŸ“Œ Overview

This project implements an autoencoder using PyTorch to reconstruct handwritten digits from the MNIST dataset. The model consists of an encoder-decoder architecture with convolutional layers, batch normalization, dropout, and fully connected layers to improve learning and generalization.

✨ Features

βœ… Autoencoder Architecture: Uses convolutional layers for feature extraction and transposed convolution for reconstruction. βœ… Data Preprocessing: Normalizes pixel values to the range [0,1] and reshapes images to (1, 28, 28). βœ… GPU Support: Automatically detects and utilizes GPU for training if available. βœ… Visualization: Displays original and reconstructed images after training.

βš™οΈ Installation

πŸ“‹ Requirements

Ensure you have the following installed:

  • 🐍 Python 3.7+
  • πŸ”₯ PyTorch
  • πŸ—ƒοΈ pandas
  • πŸ“Š matplotlib

πŸ› οΈ Setup

Clone this repository and install dependencies:

$ git clone https://github.com/your-repo/autoencoder-mnist.git
$ cd autoencoder-mnist
$ pip install -r requirements.txt

πŸš€ Usage

πŸ‹οΈ Training the Autoencoder

  1. πŸ“₯ Download the MNIST dataset from Kaggle.
  2. ✏️ Modify file_path in the script to point to the dataset.
  3. ▢️ Run the script:
    python train_autoencoder.py

πŸ“Έ Visualizing Results

After training, reconstructed images will be displayed to evaluate the performance.

πŸ—οΈ Model Architecture

πŸ”· Encoder

  • πŸ—οΈ Conv2d (1 -> 32) + ReLU + BatchNorm
  • πŸ—οΈ Conv2d (32 -> 64) + ReLU + BatchNorm
  • πŸ”„ Flatten + Fully Connected (6477 -> 128) + Dropout

πŸ”Ά Decoder

  • πŸ”„ Fully Connected (128 -> 6477) + BatchNorm
  • πŸ”„ ConvTranspose2d (64 -> 32) + ReLU + BatchNorm
  • πŸ”„ ConvTranspose2d (32 -> 1) + Sigmoid

πŸ“Š Results

The model progressively learns to reconstruct the MNIST digits, with the Mean Squared Error loss decreasing over 30 epochs πŸ“‰.

πŸ™Œ Acknowledgments

  • πŸ“œ MNIST dataset from Kaggle.
  • πŸ“š PyTorch documentation for deep learning implementation.

πŸ“œ License

This project is licensed under the MIT License πŸ“„.