ForwardDiff.jl
ForwardDiff.jl copied to clipboard
How to compute tensor
Hi, I have defined a tensor like presented in the documentation:
function tensor(f, x)
n = length(x)
out = ForwardDiff.jacobian(y -> ForwardDiff.hessian(f, y), x)
return reshape(out, n, n, n)
end
But when defined like this the tensors are just full of NaNs...
I used a simple Rosenbrock function as an example.
f(x) = 100*(x[2]-x[1]^2)^2+(x[1]-1)^2
The gradient are hessians are working just fine.