EulerSolver#
- class deepinv.sampling.EulerSolver(timesteps=None, t_start=None, t_end=None, num_steps=None, rng=None)[source]#
Bases:
BaseSDESolverEuler-Maruyama solver for SDEs.
This solver uses the Euler-Maruyama method to numerically integrate SDEs. It is a first-order method that approximates the solution using the following update rule:
\[x_{t+dt} = x_t + f(x_t,t)dt + g(t) W_{dt}\]where \(W_t\) is a Gaussian random variable with mean 0 and variance dt.
- Parameters:
timesteps (torch.Tensor, numpy.ndarray, list) – The time steps at which to evaluate the solution.
timesteps – 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.rng (torch.Generator) – A random number generator for reproducibility.
Note
You can either provide the
timestepsargument directly, or specifyt_start,t_end, andnum_stepsto generate the time steps automatically (linearly with constant stepsize). If both are provided, thetimestepsargument will take precedence.
Examples using EulerSolver:#
Using state-of-the-art diffusion models from HuggingFace Diffusers with DeepInverse
Building your diffusion posterior sampling method using SDEs
Flow-Matching for posterior sampling and unconditional generation