Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to avoid underflow in dt in dopri5? #27

Closed
simitii opened this issue Feb 4, 2019 · 5 comments
Closed

how to avoid underflow in dt in dopri5? #27

simitii opened this issue Feb 4, 2019 · 5 comments

Comments

@simitii
Copy link
Contributor

simitii commented Feb 4, 2019

After some iterations, I see the underflow in dt exception coming from dopri5.py file. What should I look for in order to debug this problem?

Thanks in advance.

@rtqichen
Copy link
Owner

rtqichen commented Feb 5, 2019

This is a problem of the ODE becoming stiff, essentially acting too erratic in a region and the step size becomes so close to zero that no progress can be made in the solver. We were able to avoid this with regularization such as weight decay and using "nice" activation functions, but YMMV. Another option is to use a fixed step size solver to get an approximate solution.

@rtqichen rtqichen closed this as completed Feb 5, 2019
@HelenZhuE
Copy link

HelenZhuE commented Feb 15, 2019

I got the same error unfortunately. How can I use a fixed step size solver to get an approximate solution? Can you able to provide me some code about it?

@simitii
Copy link
Contributor Author

simitii commented Feb 15, 2019

@HelenZhuE
just give method as parameter:
odeint(func, y0, t, method="fixed_adams")

Adaptive-step:

  • dopri5 Runge-Kutta 4(5) [default].
  • adams Adaptive-order implicit Adams.

Fixed-step:

  • euler Euler method.
  • midpoint Midpoint method.
  • rk4 Fourth-order Runge-Kutta with 3/8 rule.
  • explicit_adams Explicit Adams.
  • fixed_adams Implicit Adams.

@jandono
Copy link

jandono commented Jun 24, 2019

This is a problem of the ODE becoming stiff, essentially acting too erratic in a region and the step size becomes so close to zero that no progress can be made in the solver. We were able to avoid this with regularization such as weight decay and using "nice" activation functions, but YMMV. Another option is to use a fixed step size solver to get an approximate solution.

@rtqichen I am experiencing the same issues. Can you be more precise on which activation functions are considered nice and why? I have tried using ReLU and Softplus and I get the error with both.

Swapping the solver to 'rk4', solved the issue for me, however I am not sure how much performance I might lose because of this.

Additionally, it might be worth noting that even with the nans, the model was working and learning. I was only able to notice a problem and the nans once I run within the torch.autograd.detect_anomaly() scope. Can anyone explain this?

@densechen
Copy link

@simitii @jandono I got the same error, however I found that the NaN will occur while forward computing, and caused this error. And I have tried many method, including different non-linearity function, different solver, but all failed.
Can you give me same advice on how to debug this?
Best
Chen

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants