Hello,
is it possible to use ForwardDiff in the following way. I have a function (a forward diff through a neural network). I want to take the second derivative of the output with respect to the input.
If I use n input points, the n outputs are point independent.
Is it possible to use ForwardDiff for this? (The Jacobian obviously takes too many derivatives).
Hi I wrote an own small extension for the forwardDiff api.
Maby someone will need this too:
@inline function derivative(f::F, x::AbstractArray{R}) where {F,R<:Real}
T = typeof(ForwardDiff.Tag(f, R))
dual_vec = ForwardDiff.Dual{T}.(x, ones(size(x)))
return ForwardDiff.extract_derivative(T,f(dual_vec))
end