Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for geodesic accelaration with vector function #219

Open
albertomercurio opened this issue Jul 7, 2022 · 0 comments
Open

Support for geodesic accelaration with vector function #219

albertomercurio opened this issue Jul 7, 2022 · 0 comments

Comments

@albertomercurio
Copy link

Hello,

I'm yet able to fit a vector model, that is model(x, p) returns an array of dimensions (2, N), where N is the dimension of the x data points. I'm yet using forward differentiation ad a numerical computed Jacobian

model_jac(x, p) = ForwardDiff.jacobian(z->model(x, z), p)

and it fits very well.

Now I want to use geodesic acceleration to see if I can increase the accuracy. Taking the example in the Readme file, in which they calculate the hessian with hessian(z->model(in_data[i], z),p), I needed first to define the hessian of a vector function, which, following this issue, can be defined as

function vector_hessian(f, x)
    n = length(x)
    out = ForwardDiff.jacobian(x -> ForwardDiff.jacobian(f, x), x)
    return reshape(out, n, n, 2) # here 2 is the dimension that my function returns since I calculate the hessian(z->model(in_data[i], z),p)
end

However, if I declare my Avv! function with this 'vectorized' hessian, it gives me the error

MethodError: no method matching *(::Matrix{Float64}, ::Array{Float64, 3})

since my hessian is not a Matrix anymore.

Is there any way to make this simple extension work?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant