MCPcopy Create free account
hub / github.com/rtqichen/torchdiffeq / test_gradient

Method test_gradient

tests/api_tests.py:28–39  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

26 self.assertLess(max_error1, eps)
27
28 def test_gradient(self):
29 for device in DEVICES:
30 f, y0, t_points, sol = construct_problem(device=device)
31 tuple_f = lambda t, y: (f(t, y[0]), f(t, y[1]))
32 for method in ADAPTIVE_METHODS:
33 if method == "scipy_solver":
34 continue
35
36 with self.subTest(device=device, method=method):
37 for i in range(2):
38 func = lambda y0, t_points: torchdiffeq.odeint(tuple_f, (y0, y0), t_points, method=method)[i]
39 self.assertTrue(torch.autograd.gradcheck(func, (y0, t_points)))
40
41
42if __name__ == '__main__':

Callers

nothing calls this directly

Calls 1

construct_problemFunction · 0.90

Tested by

no test coverage detected