Skip to content
Discussion options

You must be logged in to vote

This is expected behavior because the gradient calculation here can be numerically problematic. Remember that (f/g)' = (f'g - g'f/)g^2. The g^2 here grows to a very large number when the input is close to 2.2 and for the standard 32 bit precision floats, we indeed get an inf value. At the same time the numerator of the derivative has problems of its own, since we end having to evaluate inf-inf which gives nan. Unless we are very careful about how we apply the chain rule, we can end up getting a nan.

Increasing the precision to 64 bits is sufficient to sidestep the problem for the given range because 64 bits are sufficient to represent these values (The problem reemerges if we extend the i…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@smao-astro
Comment options

Answer selected by smao-astro
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants