ForwardDiff.jl
ForwardDiff.jl copied to clipboard
Product of Inf terms leading to NaNs
ForwardDiff (v1.0.1 as well as v0.10.38) fails to compute the gradient when the inputs are too large for the following function.
julia> using ForwardDiff
julia> foo(a) = a[1] * exp(-a[2])
foo (generic function with 1 method)
julia> ForwardDiff.gradient(foo, [1., -1e3])
2-element Vector{Float64}:
NaN
NaN
The correct gradient should be [Inf, -Inf]. This works for values a2 small enough such that exp(a2) is finite.