-
Notifications
You must be signed in to change notification settings - Fork 4.4k
use int64 steps, check for NaN actions #4607
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
Conversation
still needs tests and handle torch
| action = run_out.get("action") | ||
| # Fast NaN check on the action | ||
| # See https://stackoverflow.com/questions/6736590/fast-check-for-nan-in-numpy for background. | ||
| d = np.sum(action) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's a few ways to do this; we were using np.dot for observations at one point:
| d = np.dot(np_obs, np_obs) |
but that morphed to
np.mean during some refactoring:https://github.com/Unity-Technologies/ml-agents/pull/3022/files#diff-614d11115c4d74319295ea34b44a3b7d8ab40b43865c1c3e351a8f6c9602c673R92
np.sum is one of the recommended approaches in the stackoverflow thread.
| d = np.sum(action) | ||
| has_nan = np.isnan(d) | ||
| if has_nan: | ||
| raise RuntimeError("NaN action detected.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just raising for now; there's not much the user can do about it. We could use np.nan_to_num but that would probably trigger every step and give bad results.
* check nan action for torch * step overflow test * use int tensor for global step in torch
vincentpierre
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do not forget to cherry pick on release_10 if you want these changes in the next release
* use int64 steps * check for NaN actions Co-authored-by: Ruo-Ping Dong <ruoping.dong@unity3d.com>
Proposed change(s)
Useful links (Github issues, JIRA tickets, ML-Agents forum threads etc.)
Types of change(s)
Checklist
Other comments