You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
import ForwardDiff
println("This should be 0: ",
ForwardDiff.gradient(x->log(1/max(1f-10,x[1])), zeros(Float32,1)))
println("This should be 0 too: ",
ForwardDiff.gradient(x->log(1/max(1f-20,x[1])), zeros(Float32,1)))
output is:
This should be 0: Float32[-0.0]
This should be 0 too: Float32[NaN32]
I guess this looks like some kind of overflow problem, but the number isn't that big, so I wouldn't expect overflow here.
ForwardDiff version is 0.7
julia version is 0.6.2 (2017-12-13 18:08 UTC) x86_64-linux-gnu.
Activity
fredrikekre commentedon Jan 5, 2018
You can set
ForwardDiff.jl/src/prelude.jl
Line 1 in 49292ee
true, see #179 and linked issuesmicklat commentedon Jan 5, 2018
Thanks, that worked around it! I wonder how nans got into this in the first place.
micklat commentedon Jan 5, 2018
Oh I see, the drivative of 1/x overflows when x=1f-20.
jrevels commentedon Jan 18, 2018
Closing since this seems resolved, but feel to reopen if there's still an issue here!