Diffusion Models Explained

Introduction

Diffusion models are a class of generative models that learn to generate data by reversing a gradual noising process. They have achieved state-of-the-art results in image generation, surpassing GANs in many benchmarks.

Forward Process (Adding Noise)

The forward process gradually adds Gaussian noise to data x0x_0 over TT timesteps:

q(xtxt1)=N(xt;1βtxt1,βtI)q(x_t | x_{t-1}) = \mathcal{N}(x_t; \sqrt{1-\beta_t} x_{t-1}, \beta_t I)

where βt\beta_t is the noise schedule. We can sample xtx_t directly from x0x_0:

q(xtx0)=N(xt;αˉtx0,(1αˉt)I)q(x_t | x_0) = \mathcal{N}(x_t; \sqrt{\bar{\alpha}_t} x_0, (1 - \bar{\alpha}_t)I)

where αt=1βt\alpha_t = 1 - \beta_t and αˉt=s=1tαs\bar{\alpha}_t = \prod_{s=1}^{t} \alpha_s.

Reverse Process (Denoising)

The model learns to reverse the noising process:

pθ(xt1xt)=N(xt1;μθ(xt,t),σt2I)p_\theta(x_{t-1} | x_t) = \mathcal{N}(x_{t-1}; \mu_\theta(x_t, t), \sigma_t^2 I)

Training Objective

The simplified training objective is:

Lsimple=Et,x0,ϵ[ϵϵθ(xt,t)2]L_{\text{simple}} = \mathbb{E}_{t, x_0, \epsilon}\left[\|\epsilon - \epsilon_\theta(x_t, t)\|^2\right]

where ϵθ\epsilon_\theta is a neural network (typically a U-Net) that predicts the noise.

Sampling

To generate new data, start from pure noise xTN(0,I)x_T \sim \mathcal{N}(0, I) and iteratively denoise:

xt1=1αt(xt1αt1αˉtϵθ(xt,t))+σtzx_{t-1} = \frac{1}{\sqrt{\alpha_t}}\left(x_t - \frac{1-\alpha_t}{\sqrt{1-\bar{\alpha}_t}}\epsilon_\theta(x_t, t)\right) + \sigma_t z

where zN(0,I)z \sim \mathcal{N}(0, I).

Key Variants

Applications

Conclusion

Diffusion models provide a principled framework for generative modeling with stable training and high-quality outputs, making them one of the most important developments in modern generative AI.

References

  1. Ho et al., "Denoising Diffusion Probabilistic Models," NeurIPS 2020.
  2. Song et al., "Score-Based Generative Modeling through SDEs," ICLR 2021.
  3. Rombach et al., "High-Resolution Image Synthesis with Latent Diffusion Models," CVPR 2022.