Skip to content

Product of Inf terms leading to NaNs #745

@Uroc327

Description

@Uroc327

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions