Skip to content

ForwardDiff.gradient(x->log(1/max(1f-20,x[1])), zeros(Float32,1))) returns [NaN32] #287

@micklat

Description

@micklat

Hi and thanks for ForwardDiff!

I've ran into what seems like a bug:

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.

HTH.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions