Skip to content

Custom loss function with Hessians #625

Answered by MilesCranmer
mirjanic asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @mirjanic,

Maybe you could use eval_grad_tree_array to get the 1st order derivatives, and then use finite difference to get the 2nd order differences? It might even be faster than computing the exact Hessian.

Also check through other discussions in the forums, there are a few about including derivatives in the custom loss that might be useful.

Cheers,
Miles

P.S., Another option is Enzyme.jl as explained here: https://symbolicml.org/DynamicExpressions.jl/dev/eval/#Enzyme. However, this is experimental and won't be easy. It will require you to get pretty deep into the Julia codebase. But if this is really important for you then it's worth considering. I do think that Enzyme will eventual…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by mirjanic
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants