HeunSolver#
- class deepinv.sampling.HeunSolver(timesteps, rng=None)[source]#
Bases:
BaseSDESolver
Heun 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) – The time steps at which to evaluate the solution.
rng (torch.Generator) – A random number generator for reproducibility.
- step(sde, t0, t1, x0, *args, **kwargs)[source]#
Perform a single step with step size from time
t0
to timet1
, with current statex0
.- Parameters:
sde (deepinv.sampling.BaseSDE) – the SDE to solve.
t0 (float or torch.Tensor) – Time at the start of the step, of size (,).
t1 (float or torch.Tensor) – Time at the end of the step, of size (,).
x0 (torch.Tensor) – Current state of the system, of size (batch_size, d).
- Returns:
Updated state of the system after the step.
- Return type: