This project implements a Denoising Diffusion Probabilistic Model (DDPM) from scratch to understand the forward noising process, reverse denoising process, and the mathematical intuition behind diffusion-based generative models.
The emphasis of this repository is conceptual correctness and training dynamics, not pretrained weights or plug-and-play inference.
model.pt) are not included in this repository.
The model was trained locally, but the checkpoint was not saved.
This repository is intended to:
- Demonstrate a correct DDPM implementation
- Show understanding of diffusion mechanics
- Serve as a learning and experimentation reference
Re-training the model is straightforward using the provided code.
Diffusion models form the backbone of:
- Stable Diffusion
- Image and audio generation systems
- Modern generative AI pipelines
Understanding DDPMs requires:
- Probability theory
- Stochastic processes
- Careful loss and noise scheduling
This project focuses on those internals, not abstraction layers.
- Forward diffusion (progressive Gaussian noise injection)
- Reverse diffusion (learned denoising process)
- Noise schedule (β, α, and cumulative products)
- Time-step conditioning
- Mean Squared Error (MSE) noise prediction objective
- U-Net–style architecture
- Time-step embeddings
- Skip connections for stable gradient flow
Design choices prioritize:
- Training stability
- Interpretability
- Alignment with original DDPM formulation
The model is trained to predict the noise added at each timestep:
[ L = \mathbb{E}{x_0, \epsilon, t} [|| \epsilon - \epsilon\theta(x_t, t) ||^2 ] ]
This formulation ensures:
- Stable optimization
- Clear separation between noise and signal
- Image dataset (e.g., MNISTimages)
The dataset is intentionally simple to focus on diffusion behavior, not dataset complexity.
- Progressive denoising observed across timesteps
- Sensitivity to noise schedule parameters
- Training instability when β schedule is poorly chosen
Sample outputs can be regenerated by retraining the model.
├── result/
├── notebooks/
└── README.md
- How diffusion models differ from GANs and VAEs
- Importance of noise schedules
- Why diffusion training is stable but slow
- Relationship between score matching and denoising
- No pretrained weights included
- Training requires significant compute for high-quality samples
- Focused on correctness over optimization
- Save and version model checkpoints
- Improved noise schedules (cosine, learned)
- Class-conditional diffusion
- Latent diffusion models
Hasan Kabir AI / Generative Models Engineer
This repository reflects a theory-first approach to diffusion models. The absence of pretrained weights does not reduce the technical depth of the implementation.