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

Function construct_problem

tests/problems.py:79–95  ·  view source on GitHub ↗
(device, npts=10, ode='constant', reverse=False, dtype=torch.float64)

Source from the content-addressed store, hash-verified

77
78
79def construct_problem(device, npts=10, ode='constant', reverse=False, dtype=torch.float64):
80
81 f = PROBLEMS[ode]().to(dtype=dtype, device=device)
82
83 t_points = torch.linspace(1, 8, npts, dtype=torch.float64, device=device, requires_grad=True)
84 sol = f.y_exact(t_points).to(dtype)
85
86 def _flip(x, dim):
87 indices = [slice(None)] * x.dim()
88 indices[dim] = torch.arange(x.size(dim) - 1, -1, -1, dtype=torch.long, device=device)
89 return x[tuple(indices)]
90
91 if reverse:
92 t_points = _flip(t_points, 0).clone().detach()
93 sol = _flip(sol, 0).clone().detach()
94
95 return f, sol[0].detach().requires_grad_(True), t_points, sol
96
97
98if __name__ == '__main__':

Callers 12

test_odeintMethod · 0.90
test_adjointMethod · 0.90
test_odeintMethod · 0.90
test_odeintMethod · 0.90
test_min_max_stepMethod · 0.90
test_odeintMethod · 0.90
test_adjointMethod · 0.90
test_odeintMethod · 0.90
test_adjointMethod · 0.90
test_forwardMethod · 0.90
test_gradientMethod · 0.90

Calls 2

_flipFunction · 0.85
y_exactMethod · 0.45

Tested by 12

test_odeintMethod · 0.72
test_adjointMethod · 0.72
test_odeintMethod · 0.72
test_odeintMethod · 0.72
test_min_max_stepMethod · 0.72
test_odeintMethod · 0.72
test_adjointMethod · 0.72
test_odeintMethod · 0.72
test_adjointMethod · 0.72
test_forwardMethod · 0.72
test_gradientMethod · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…