To generate an image, start from pure noise x_T and denoise one step at a time, from T down to 1. A DDPM reverse step takes the current noisy image x_t, asks the network for its noise estimate, and computes the mean of a Gaussian over the slightly less noisy x_{t-1}. The mean subtracts the predicted noise, scaled by a factor that depends on the schedule: mu = (x_t - beta_t / sqrt(1 - ab_t) * eps) / sqrt(alpha_t) where alpha_t = 1 - beta_t. Then a bit of fresh Gaussian noise with standard deviation sqrt(beta_t) is added back, except at the very last step where the output should be the clean sample. That injected noise makes DDPM sampling stochastic.
Implement ddpm_step.
ddpm_step(x_t, eps_pred, t, betas, alpha_bars, z) uses 0-based t (index into betas and alpha_bars), with alpha_t = 1 - betas[t].mu = (x_t - betas[t] / sqrt(1 - alpha_bars[t]) * eps_pred) / sqrt(alpha_t).t > 0 return mu + sqrt(betas[t]) * z. If t == 0 return mu with no noise added.z is standard Gaussian noise of the same shape as x_t, passed in so the step is deterministic.Compute the mean first, then decide whether to add noise.
The noise at the last step is omitted because adding noise to the final image would only degrade it.
No results yet
Run your code to check it against the examples, or submit to run every test.