rtqichen / torchdiffeq

Differentiable ODE solvers with full GPU support and O(1)-memory backpropagation.
MIT License
5.61k stars 930 forks source link

Solving a system of ODEs #195

Open ojus1 opened 2 years ago

ojus1 commented 2 years ago

Hi, great work, and thanks for the code!

I was wondering if the following is possible. I have a system of ODEs (two ODEs): x_state = f(x, t, theta) 0 = d {g(x, t, phi)} / dx Simply put, I want the function f to output something that doesn't change the output of the function g. f and g both are Neural ODEs. I want to learn the parameters of both f and g at the same time.

Any example code would help a lot!

Thanks in advance.

Saltsmart commented 2 years ago

What's the meaning of x_state? Does it coupled with g?

ojus1 commented 2 years ago

Yes, there is a coupling between g and x.

jotaf98 commented 2 years ago

Simply put, I want the function f to output something that doesn't change the output of the function g.

If this output x_state doesn't affect g, but you want to access it outside, I'd just create f as an instance of a callable class instead of a function, and store x_state inside as an attribute. After the ODE is solved you can access it outside.