easy primitives

DDPM Noise Schedule

Implement the linear beta schedule used in Denoising Diffusion Probabilistic Models (DDPM).

Background

Diffusion models learn to reverse a gradual noising process. The forward process adds Gaussian noise in small steps controlled by a noise schedule — a sequence of variance values beta_1, ..., beta_T.

The linear schedule (Ho et al. 2020) spaces these values evenly:

betas = linspace(beta_start, beta_end, T)

From the betas we derive alpha_bar, the cumulative signal-preservation factor:

alpha_bar[t] = prod(1 - betas[0:t+1])

alpha_bar[t] tells you how much of the original signal remains after t steps of noising. At t=0 it is close to 1 (little noise added); by t=T-1 it is small (mostly noise).

Algorithm

betas     = linspace(beta_start, beta_end, num_steps)
alphas    = 1 - betas
alpha_bar = cumprod(alphas)   # cumulative product along T
return stack([betas, alpha_bar], dim=0)   # shape (2, T)

Reference

Ho et al., “Denoising Diffusion Probabilistic Models” (2020).

Inputs / Output

  • num_steps: int T — number of diffusion timesteps (e.g., 1000).
  • beta_start: float — starting variance (default 1e-4).
  • beta_end: float — ending variance (default 0.02).

Output: shape (2, T) tensor — row 0 is betas, row 1 is alpha_bar.

Hints

generative diffusion ddpm

Sign in to attempt this problem and view the solution.