src.diffusion.ddim module#
- class src.diffusion.ddim.DDIM(args: Namespace, eta=0.0)[source]#
Bases:
DDPMDenoising Diffusion Implicit Model (DDIM).
Inherits from DDPM. DDIM enables faster sampling with skipped steps while preserving generation quality through a non-Markovian reverse process.
- __init__(args: Namespace, eta=0.0)[source]#
Initialize the DDIM sampler.
- Parameters:
args (Namespace) – Configuration argument object.
eta (float, optional) – Hyperparameter controlling the stochasticity of the sampling process. - eta=0.0: deterministic sampling (Standard DDIM). - eta=1.0: DDPM-equivalent variance (Standard DDPM). Default is 0.0.
- denoise(xt, denoise_t, x0=None, noise=None, stride=1)[source]#
DDIM reverse process: deterministically or semi-deterministically derive x_{t-stride} from x_t.
This method overrides the parent DDPM.denoise implementation and uses the DDIM update rule.
- x_{t-1} = sqrt(alpha_bar_{t-1}) * “predicted x0” +
sqrt(1 - alpha_bar_{t-1} - sigma_t^2) * “predicted noise” + sigma_t * epsilon_t
- Parameters:
xt (torch.FloatTensor) – Noisy data at the current timestep t.
denoise_t (torch.LongTensor) – Index of the current timestep t.
x0 (torch.FloatTensor, optional) – Model-predicted original data x0.
noise (torch.FloatTensor, optional) – Model-predicted noise epsilon. Note: exactly one of x0 and noise must be provided.
stride (int, optional) – Sampling step size used for acceleration. Default is 1.
- Returns:
Denoised data at the previous step x_{t-stride}.
- Return type:
torch.FloatTensor