HeunSolver#
- class deepinv.sampling.HeunSolver(timesteps=None, t_start=None, t_end=None, num_steps=None, rng=None)[source]#
Bases:
BaseSDESolverHeun solver for SDEs.
This solver uses the second-order Heun method to numerically integrate SDEs, defined as:
\[\begin{split}\tilde{x}_{t+dt} &= x_t + f(x_t,t)dt + g(t) W_{dt} \\ x_{t+dt} &= x_t + \frac{1}{2}[f(x_t,t) + f(\tilde{x}_{t+dt},t+dt)]dt + \frac{1}{2}[g(t) + g(t+dt)] W_{dt}\end{split}\]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.