torchdiffeq icon indicating copy to clipboard operation
torchdiffeq copied to clipboard

Questions about time step

Open raabuchanan opened this issue 3 years ago • 1 comments

Hi there I'm trying to use odeint with my own network and I'm having trouble with the forward pass taking extremely long. I print the timestamps in the forward pass and I've noticed two things:

  • The time step size is extremely small, like 0.0001. Even though I've only given 10 timestamps as np.arange(0, 0.1, 0.01)
  • Many timestamps are repeated, for example it will do a forward pass with time 0.0007 148 times before then doing time 0.0008.

Am I doing something wrong or is this expected behaviour? When I run ode_demo.py the time steps are much more reasonable in terms of size and there is no repetition of timestamps.

Thanks Russell

raabuchanan avatar Aug 02 '21 09:08 raabuchanan

If the ODE system is hard to solve, it's normal to take small step sizes. For adaptive step size solvers, if you want to increase step sizes at the expense of some numerical accuracy, you can increase the values of atol and rtol. The repeated timestamps is normal, it's an indication of a step being rejected due to failing to meet the desired numerical tolerance. A smaller step size will be retried afterwards.

Otherwise, you can also just specify the step sizes yourself with a fixed step size scheme like rk4.

rtqichen avatar Aug 03 '21 03:08 rtqichen