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

missing Jacobian and Hessian methods #54

Open
CarloLucibello opened this issue Feb 20, 2018 · 2 comments · May be fixed by #57
Open

missing Jacobian and Hessian methods #54

CarloLucibello opened this issue Feb 20, 2018 · 2 comments · May be fixed by #57

Comments

@CarloLucibello
Copy link
Collaborator

CarloLucibello commented Feb 20, 2018

eventually trough Jacobian-vector product. Nice related blog post https://j-towns.github.io/2017/06/12/A-new-trick.html

@jbrea
Copy link

jbrea commented Oct 10, 2019

I see in @CarloLucibello's PR #57 how to compute hessians with the old interface.
Is there an easy way to compute hessians also with the new interface?

@denizyuret
Copy link
Owner

You can still use the old interface, here is an example from our SGDDynamics project:

function hessian(loss,w,x,y)
    ∇loss = grad(loss)
    ∇lossi(w,x,y,i) = ∇loss(w,x,y)[i]
    ∇∇lossi = grad(∇lossi)
    w = value(w)
    n = length(w)
    h = similar(Array(w),n,n)
    for i in progress(1:n)
        h[:,i] .= Array(vec(∇∇lossi(w,x,y,i)))
    end
    return h
end

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

Successfully merging a pull request may close this issue.

3 participants