This repository contains learning-oriented PyTorch implementations of basic deep generative models. The code was written as part of self-study to understand the fundamentals of variational autoencoders, generative adversarial networks, and diffusion-based generative models.
The implementations in this repository were developed after completing the lecture series:
Mathematical Foundations of Generative AI - YouTube Playlist
Instructor: Prof. Prathosh A P
Offered by IIT Madras
Division of Electrical, Electronics, and Computer Science (EECS), IISc Bangalore
The course provided the theoretical foundations for variational inference, adversarial learning, and diffusion-based generative modeling.
- Encoder–decoder architecture
- Reparameterization trick
- Reconstruction loss with KL divergence regularization
- Convolutional GAN architecture for MNIST
- Separate generator and discriminator networks trained adversarially
- Binary cross-entropy objective implemented using
BCEWithLogitsLoss - Alternating optimization of generator and discriminator
- Sampling via latent noise vectors
- Forward noising and reverse denoising processes
- Noise prediction objective using MSE loss
- Sampling via the standard DDPM reverse process
- Class-conditional diffusion model
- Classifier-free guidance implemented via random label dropping during training
- Adjustable guidance scale during sampling
Deep_Generative_Modelling/
├── models/
│ ├── vae/
│ ├── gan/
│ └── diffusion/
├── train/
├── eval/
├── sample/
├── checkpoints/
├── data/
├── legacy/
├── requirements.txt
└── README.md
- To understand generative modeling concepts by implementing them from scratch
- To experiment with VAEs, GANs, and diffusion models in PyTorch
- To analyze training dynamics (loss behavior, adversarial balance, sampling quality)
- To serve as a base for further learning and extensions
- Python 3.9+
- PyTorch
- torchvision
- numpy
- matplotlib
Install dependencies using:
pip install -r requirements.txt
Train models using:
python train/train_vae.py
python train/train_gan.py
python train/train_ddpm.py
Sample from trained models using:
python eval/gan/sample_gan.py
python sample/sample_ddpm.py
Trained model checkpoints are expected in the checkpoints/ directory.