DDPMConfig
DiffusionModelConfigDDPMConfig(sample_size: int | tuple[int, int] = 32, in_channels: int = 3, out_channels: int = 3, act_fn: GenerativeActivation = 'silu', num_train_timesteps: int = 1000, beta_start: float = 0.0001, beta_end: float = 0.02, beta_schedule: BetaSchedule = 'linear', prediction_type: Literal['epsilon', 'sample', 'v_prediction'] = 'epsilon', base_channels: int = 128, channel_mult: tuple[int, ...] = (lambda: (1, 2, 2, 2))(), num_res_blocks: int = 2, attention_resolutions: tuple[int, ...] = (lambda: (16,))(), num_heads: int = 1, dropout: float = 0.1, resnet_groups: int = 32, use_scale_shift_norm: bool = False, rescale_timesteps: bool = False, learn_sigma: bool = False, vlb_weight: float = 0.001, clip_denoised: bool = True)Configuration for every DDPM variant.
Args:
base_channels: Channel width of the first U-Net stage C_0. All
other stages are integer multiples (see channel_mult).
Paper default: 128.
channel_mult: Per-stage channel multiplier. (1, 2, 2, 2) for
CIFAR (Table 9), (1, 1, 2, 2, 4, 4) for LSUN/CelebA-HQ.
Length = number of downsampling stages; spatial resolution
divides by 2 ** (L - 1) (no downsample after the final
stage).
num_res_blocks: ResBlocks per stage (paper: 2).
attention_resolutions: Spatial sizes at which self-attention is
applied. Ho 2020 uses (16,) — attention only at the
16×16 feature scale.
num_heads: Attention head count (paper: 1 for CIFAR, can scale).
dropout: Dropout inside ResBlocks. Paper: 0.1 (CIFAR), 0.0
(CelebA / LSUN).
resnet_groups: GroupNorm group count inside ResBlocks (paper
default: 32). Must divide every per-stage channel count.
learn_sigma: Improved-DDPM (Nichol 2021) — when True, the
network predicts the variance in addition to the mean. Output
channels become 2 * in_channels, and training switches to
the hybrid objective (see vlb_weight), since the fixed
simple loss carries no signal for a variance head.
vlb_weight: The λ on the variational term of
L_simple + λ·L_vlb (Nichol & Dhariwal 2021 §4; default
1e-3). Only read when learn_sigma=True.
clip_denoised: Clip the predicted x_0 to [-1, 1] during
sampling (default True).
Examples
>>> from lucid.models.generative.ddpm._config import DDPMConfig
>>> cfg = DDPMConfig()
>>> cfg.model_type
'ddpm'
>>> cfg.in_channels
3Used by 5
Constructors
1__init__
→None__init__(sample_size: int | tuple[int, int] = 32, in_channels: int = 3, out_channels: int = 3, act_fn: GenerativeActivation = 'silu', num_train_timesteps: int = 1000, beta_start: float = 0.0001, beta_end: float = 0.02, beta_schedule: BetaSchedule = 'linear', prediction_type: Literal['epsilon', 'sample', 'v_prediction'] = 'epsilon', base_channels: int = 128, channel_mult: tuple[int, ...] = (lambda: (1, 2, 2, 2))(), num_res_blocks: int = 2, attention_resolutions: tuple[int, ...] = (lambda: (16,))(), num_heads: int = 1, dropout: float = 0.1, resnet_groups: int = 32, use_scale_shift_norm: bool = False, rescale_timesteps: bool = False, learn_sigma: bool = False, vlb_weight: float = 0.001, clip_denoised: bool = True)