How to use the torchdiffeq._impl.misc._select_initial_step function in torchdiffeq

To help you get started, we’ve selected a few torchdiffeq examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github rtqichen / torchdiffeq / torchdiffeq / _impl / adaptive_heun.py View on Github external
def before_integrate(self, t):
        f0 = self.func(t[0].type_as(self.y0[0]), self.y0)
        if self.first_step is None:
            first_step = _select_initial_step(self.func, t[0], self.y0, 4, self.rtol[0], self.atol[0], f0=f0).to(t)
        else:
            first_step = _convert_to_tensor(0.01, dtype=t.dtype, device=t.device)
        self.rk_state = _RungeKuttaState(self.y0, f0, t[0], t[0], first_step, interp_coeff=[self.y0] * 5)
github uncbiag / easyreg / torchdiffeq / _impl / dopri5.py View on Github external
def before_integrate(self, t):
        f0 = self.func(t[0].type_as(self.y0[0]), self.y0)
        #print("first_step is {}".format(self.first_step))
        if self.first_step is None:
            first_step = _select_initial_step(self.func, t[0], self.y0, 4, self.rtol[0], self.atol[0], f0=f0).to(t)
        else:
            first_step = _convert_to_tensor(0.01, dtype=t.dtype, device=t.device)
        # if first_step>0.2:
        #     print("warning the first step of dopri5 {} is too big, set to 0.2".format(first_step))
        #     first_step = _convert_to_tensor(0.2, dtype=torch.float64, device=self.y0[0].device)

        self.rk_state = _RungeKuttaState(self.y0, f0, t[0], t[0], first_step, interp_coeff=[self.y0] * 5)