DDIMSolver#
- class deepinv.sampling.DDIMSolver(timesteps=None, t_start=None, t_end=None, num_steps=None, eta=0.0, variance='small', rng=None)[source]#
Bases:
AncestralSolverDDIM solver for reverse-time diffusion SDEs.
Sampler of DDIM [1] with the stochasticity parameter \(\eta\). The default \(\eta = 0\) gives the deterministic DDIM sampler and \(\eta = 1\) gives the DDPM sampler, see
deepinv.sampling.DDPMSolver.The
alphaof the SDE is ignored, and replaced on each step ofdeepinv.sampling.AncestralSolverby\[\alpha_\eta = \frac{\log\left(1 - \eta^2 (1 - r^2)\right)}{2 \log r}, \quad r = \frac{\sigma(t+dt)}{\sigma(t)}.\]This relation depends on the step: \(\alpha_\eta = \eta\) for \(\eta \in \{0, 1\}\), and \(\alpha_\eta\) tends to \(\eta^2\) for small steps.
With
variance="large", the noise is scaled by \(s(t) \sigma(t) / (s(t+dt) \sigma(t+dt))\), seedeepinv.sampling.AncestralSolver. For \(\eta = 1\), this is the DDPM sampler with the variance \(\beta_t\) of the forward transition.- Parameters:
timesteps (torch.Tensor, numpy.ndarray, list) – time steps at which the SDE will be discretized.
t_start (float) – the starting time of the SDE, optional. If not provided, it will be inferred from the
timestepsargument.t_end (float) – the ending time of the SDE, optional. If not provided, it will be inferred from the
timestepsargument.num_steps (int) – the number of time steps for the SDE, optional. If not provided, it will be inferred from the
timestepsargument.eta (float) – the stochasticity parameter \(\eta \in [0, 1]\) of DDIM. Default to
0.variance (str) – the variance of the noise added on each step, either
"small"(default) or"large", seedeepinv.sampling.AncestralSolver.rng (torch.Generator) – A random number generator for reproducibility.
- References: