HeunIntegrator
Methods and Attributes¶
Bases: BaseIntegrator
Heun integrator (predictor-corrector) for Itô SDEs and ODEs.
A second-order method that uses a predictor step followed by a corrector:
\[ \mathrm{d}x = f(x,t)\,\mathrm{d}t + \sqrt{2D(x,t)}\,\mathrm{d}W_t \]
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
device | Optional[device] | Device for computations. | None |
dtype | Optional[dtype] | Data type for computations. | None |
Example
Source code in torchebm/integrators/heun.py
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 | |
step ¶
step(state: Dict[str, Tensor], model: Optional[BaseModel], step_size: Tensor, *, drift: Optional[Callable[[Tensor, Tensor], Tensor]] = None, diffusion: Optional[Tensor] = None, t: Tensor, noise: Optional[Tensor] = None, noise_scale: Optional[Tensor] = None) -> Dict[str, torch.Tensor]
Source code in torchebm/integrators/heun.py
integrate ¶
integrate(state: Dict[str, Tensor], model: Optional[BaseModel], step_size: Tensor, n_steps: int, *, drift: Optional[Callable[[Tensor, Tensor], Tensor]] = None, diffusion: Optional[Callable[[Tensor, Tensor], Tensor]] = None, noise_scale: Optional[Tensor] = None, t: Tensor) -> Dict[str, torch.Tensor]