YAML Metadata
Warning:
empty or missing yaml metadata in repo card
(https://huggingface.co/docs/hub/model-cards#model-card-metadata)
GAN Implementation - MNIST Digit Generation
A comprehensive implementation of Generative Adversarial Networks (GANs) for generating MNIST handwritten digits using PyTorch.
π₯ Features
- Complete GAN Implementation: Both standard and optimized versions
- MNIST Digit Generation: Generate realistic handwritten digits
- Multiple Training Modes: Standard and lite modes for different performance needs
- Comprehensive Logging: Detailed training logs and progress tracking
- GPU Support: MPS (Apple Silicon), CUDA, and CPU support
- Visualization: Real-time training progress and generated samples
π Results
The implementation successfully generates realistic MNIST digits with:
- Generator Parameters: 576K (lite) / 3.5M (standard)
- Discriminator Parameters: 533K (lite) / 2.7M (standard)
- Training Time: ~5 minutes (lite mode) / ~30 minutes (standard)
π Quick Start
Installation
# Clone the repository
git clone https://github.com/GruheshKurra/GAN_Implementation.git
cd GAN_Implementation
# Install dependencies
pip install -r requirements.txt
Usage
Open the Jupyter Notebook:
jupyter notebook Gan.ipynb
Run the cells to train the GAN and generate digits
Choose your mode:
- Standard Mode: Full implementation with detailed logging
- Lite Mode: Optimized for faster training and lower resource usage
π Project Structure
GAN_Implementation/
βββ Gan.ipynb # Main implementation notebook
βββ requirements.txt # Python dependencies
βββ README.md # This file
βββ Generative Adversarial Networks (GANs).md # Theory and documentation
βββ gan_training.log # Training logs (standard mode)
βββ gan_training_lite.log # Training logs (lite mode)
βββ generator_lite.pth # Saved model weights
βββ data/ # MNIST dataset
βββ MNIST/
βββ raw/ # Raw MNIST data files
π§ Implementation Details
Architecture
Generator Network:
- Input: Random noise vector (100D standard / 64D lite)
- Hidden layers with ReLU/BatchNorm activation
- Output: 784D vector (28x28 MNIST image)
- Activation: Tanh (output range [-1, 1])
Discriminator Network:
- Input: 784D image vector
- Hidden layers with LeakyReLU/Dropout
- Output: Single probability (real vs fake)
- Activation: Sigmoid
Training Process
- Data Preparation: MNIST dataset normalized to [-1, 1]
- Adversarial Training:
- Discriminator learns to distinguish real vs fake images
- Generator learns to fool the discriminator
- Loss Function: Binary Cross-Entropy Loss
- Optimization: Adam optimizer with Ξ²β=0.5, Ξ²β=0.999
π Training Modes
Standard Mode
- Latent Dimension: 100
- Epochs: 50-100
- Batch Size: 64-128
- Dataset: Full MNIST (60K samples)
- Best for: High-quality results
Lite Mode
- Latent Dimension: 64
- Epochs: 50
- Batch Size: 64
- Dataset: Subset (10K samples)
- Best for: Quick experimentation and testing
π§ Technical Features
- Device Auto-Detection: Automatically uses MPS, CUDA, or CPU
- Memory Optimization: Efficient memory usage with cache clearing
- Progress Tracking: Real-time loss monitoring and sample generation
- Model Persistence: Save/load trained models
- Comprehensive Logging: Detailed training metrics and timing
π Performance Metrics
Mode | Training Time | Generator Loss | Discriminator Loss | Quality |
---|---|---|---|---|
Standard | ~30 min | ~1.5 | ~0.7 | High |
Lite | ~5 min | ~2.0 | ~0.6 | Good |
π― Use Cases
- Educational: Learn GAN fundamentals with working code
- Research: Baseline for GAN experiments
- Prototyping: Quick testing of GAN modifications
- Production: Scalable digit generation system
π Links & Resources
- GitHub Repository: https://github.com/GruheshKurra/GAN_Implementation
- Hugging Face: https://huggingface.co/karthik-2905/GAN_Implementation
- Blog Post: [Coming Soon on daily.dev]
- Theory Documentation: See
Generative Adversarial Networks (GANs).md
π οΈ Requirements
- Python 3.7+
- PyTorch 2.0+
- torchvision 0.15+
- matplotlib 3.5+
- numpy 1.21+
- jupyter 1.0+
π License
This project is open source and available under the MIT License.
π€ Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
π Contact
- Author: Karthik
- GitHub: @GruheshKurra
π Acknowledgments
- Original GAN paper by Ian Goodfellow et al.
- PyTorch team for the excellent deep learning framework
- MNIST dataset creators
β If you find this implementation helpful, please give it a star!
Inference Providers
NEW
This model isn't deployed by any Inference Provider.
π
Ask for provider support