Bare DDPM U-Net trunk with the sampling-capable DiffusionMixin.
Returns a DiffusionModelOutput whose sample field is the
raw network output — interpreted as predicted noise ,
clean signal , or velocity depending on
config.prediction_type. When config.learn_sigma is True
the output channels are 2 * in_channels: the first half is the
mean prediction, the second half the (raw) variance prediction;
downstream code splits the two if needed.
Parameters
configDDPMConfignum_train_timesteps, beta_start,
beta_end, beta_schedule, prediction_type).Attributes
unetDDPMUNetDDPMUNet).config_classtype[DDPMConfig]base_model_prefixstr"ddpm") under which the trunk is nested in
task-head variants.Notes
Reference: Ho, Jain, and Abbeel, "Denoising Diffusion Probabilistic Models", NeurIPS, 2020 (arXiv:2006.11239).
The forward Markov chain has the closed-form marginal
with . The U-Net is trained to predict the injected noise so reverse sampling iterates via the standard ancestral Gaussian update.
Examples
>>> import lucid
>>> from lucid.models.generative.ddpm import DDPMConfig, DDPMModel
>>> cfg = DDPMConfig(sample_size=32, base_channels=32,
... channel_mult=(1, 2), num_res_blocks=1,
... resnet_groups=16, num_train_timesteps=100)
>>> model = DDPMModel(cfg).eval()
>>> x_t = lucid.randn((1, 3, 32, 32))
>>> t = lucid.tensor([42]).long()
>>> out = model(x_t, t)
>>> out.sample.shape # (1, 3, 32, 32) — predicted noise
(1, 3, 32, 32)Used by 2
Constructors
1Instance methods
1forward(sample: Tensor, timestep: Tensor)Predict noise (or [noise, σ²]) at the given timestep.
Parameters
sample(B, in_channels, H, W) noisy image x_t.timestep(B,) or () int timestep tensor. Scalar tensors
are broadcast.Returns
DiffusionModelOutput(B, out_channels_effective, H, W) raw network output.