Denoising Diffusion Probabilistic Models (DDPM)
Implementation of Denoising Diffusion Probabilistic Models (Ho, Jain, Abbeel, 2020).
What this implements
The DDPM training and sampling procedure β a class of generative models that learn to reverse a gradual noising process. The core contribution is the training objective (simplified variational bound) and the reverse sampling algorithm, NOT the U-Net architecture (which is adapted from prior work). This implementation covers the forward diffusion process, the simplified training objective (L_simple), the noise schedule, and the reverse sampling algorithm from Algorithm 1 and Algorithm 2.
Quick start
pip install -r requirements.txt
from src.model import UNet, UNetConfig
from src.loss import DDPMLoss
from src.utils import linear_noise_schedule
config = UNetConfig()
model = UNet(config)
noise_schedule = linear_noise_schedule(timesteps=1000)
# Example: predict noise from noisy image at timestep t
import torch
x_t = torch.randn(2, 3, 32, 32) # noisy image
t = torch.randint(0, 1000, (2,)) # timesteps
predicted_noise = model(x_t, t)
print(predicted_noise.shape) # (2, 3, 32, 32)
File structure
ddpm/
βββ README.md # This file
βββ REPRODUCTION_NOTES.md # Ambiguity audit β what's specified vs. assumed
βββ requirements.txt # Dependencies
βββ src/
β βββ model.py # U-Net noise prediction network (Β§3.3, Appendix B)
β βββ loss.py # DDPM simplified loss L_simple (Β§3.4, Eq. 14)
β βββ data.py # Dataset skeleton for image data
β βββ train.py # Training loop β Algorithm 1
β βββ evaluate.py # FID score computation
β βββ utils.py # Noise schedule, forward process, sampling (Algorithm 2)
βββ configs/
β βββ base.yaml # All hyperparameters from Β§4 and Appendix B
βββ notebooks/
βββ walkthrough.ipynb # Paper sections β code β sanity checks
Important: Read REPRODUCTION_NOTES.md
This implementation flags every choice that the paper does not specify. Before using this code for research, read REPRODUCTION_NOTES.md to understand which implementation details are from the paper and which are our choices.
Citation
@article{ho2020denoising,
title={Denoising diffusion probabilistic models},
author={Ho, Jonathan and Jain, Ajay and Abbeel, Pieter},
journal={Advances in neural information processing systems},
volume={33},
pages={6840--6851},
year={2020}
}
Generated by paper2code β citation-anchored paper implementation.