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.
✅ 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.
Ensure you have the following installed:
- 🐍 Python 3.7+
- 🔥 PyTorch
- 🗃️ pandas
- 📊 matplotlib
Clone this repository and install dependencies:
$ git clone https://github.com/your-repo/autoencoder-mnist.git
$ cd autoencoder-mnist
$ pip install -r requirements.txt- 📥 Download the MNIST dataset from Kaggle.
- ✏️ Modify
file_pathin the script to point to the dataset. ▶️ Run the script:python train_autoencoder.py
After training, reconstructed images will be displayed to evaluate the performance.
- 🏗️ Conv2d (1 -> 32) + ReLU + BatchNorm
- 🏗️ Conv2d (32 -> 64) + ReLU + BatchNorm
- 🔄 Flatten + Fully Connected (6477 -> 128) + Dropout
- 🔄 Fully Connected (128 -> 6477) + BatchNorm
- 🔄 ConvTranspose2d (64 -> 32) + ReLU + BatchNorm
- 🔄 ConvTranspose2d (32 -> 1) + Sigmoid
The model progressively learns to reconstruct the MNIST digits, with the Mean Squared Error loss decreasing over 30 epochs 📉.
- 📜 MNIST dataset from Kaggle.
- 📚 PyTorch documentation for deep learning implementation.
This project is licensed under the MIT License 📄.