Closed sethaxen closed 2 years ago
julia> using AbstractDifferentiation julia> ba = AD.ForwardDiffBackend(); julia> x = randn(3); julia> AD.gradient(ba, sum, x) ([1.0, 1.0, 1.0],) julia> AD.value_and_gradient(ba, sum, x) (-0.056101093099405724, ([1.0, 1.0, 1.0],)) julia> AD.value_gradient_and_hessian(ba, sum, x) (-0.056101093099405724, (ForwardDiff.Dual{ForwardDiff.Tag{ComposedFunction{typeof(AbstractDifferentiation.asarray), AbstractDifferentiation.var"#3#4"{AbstractDifferentiation.ForwardDiffBackend{Nothing}, AbstractDifferentiation.var"#9#10"{AbstractDifferentiation.ForwardDiffBackend{Nothing}, typeof(sum)}, Tuple{Vector{Float64}}}}, Float64}, Float64, 3}[Dual{ForwardDiff.Tag{ComposedFunction{typeof(AbstractDifferentiation.asarray), AbstractDifferentiation.var"#3#4"{AbstractDifferentiation.ForwardDiffBackend{Nothing}, AbstractDifferentiation.var"#9#10"{AbstractDifferentiation.ForwardDiffBackend{Nothing}, typeof(sum)}, Tuple{Vector{Float64}}}}, Float64}}(1.0,0.0,0.0,0.0), Dual{ForwardDiff.Tag{ComposedFunction{typeof(AbstractDifferentiation.asarray), AbstractDifferentiation.var"#3#4"{AbstractDifferentiation.ForwardDiffBackend{Nothing}, AbstractDifferentiation.var"#9#10"{AbstractDifferentiation.ForwardDiffBackend{Nothing}, typeof(sum)}, Tuple{Vector{Float64}}}}, Float64}}(1.0,0.0,0.0,0.0), Dual{ForwardDiff.Tag{ComposedFunction{typeof(AbstractDifferentiation.asarray), AbstractDifferentiation.var"#3#4"{AbstractDifferentiation.ForwardDiffBackend{Nothing}, AbstractDifferentiation.var"#9#10"{AbstractDifferentiation.ForwardDiffBackend{Nothing}, typeof(sum)}, Tuple{Vector{Float64}}}}, Float64}}(1.0,0.0,0.0,0.0)],), ([0.0 0.0 0.0; 0.0 0.0 0.0; 0.0 0.0 0.0],))
I think we need one more primal_value method like https://github.com/JuliaDiff/AbstractDifferentiation.jl/blob/master/src/forwarddiff.jl#L41 for arrays of duals.
primal_value