ForwardDiff.jl icon indicating copy to clipboard operation
ForwardDiff.jl copied to clipboard

How to compute tensor

Open Goysa2 opened this issue 6 years ago • 0 comments

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.

Goysa2 avatar Apr 13 '18 17:04 Goysa2