# Calculating Hessians of loss w.r.t parameters of a system of ODEs

**URL:** <https://discourse.julialang.org/t/calculating-hessians-of-loss-w-r-t-parameters-of-a-system-of-odes/99025>\
**Category:** Machine Learning\
**Tags:** dynamical-systems\
**Created:** [May 17, 2023, 11:31pm UTC](https://discourse.julialang.org/t/calculating-hessians-of-loss-w-r-t-parameters-of-a-system-of-odes/99025 "2023-05-17T23:31:57Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![KK\_JuliaNoob](https://avatars.discourse-cdn.com/v4/letter/k/9de0a6/32.png) [@KK\_JuliaNoob](https://discourse.julialang.org/u/KK_JuliaNoob)\
**Post date:** [May 17, 2023, 11:31pm UTC](https://discourse.julialang.org/t/calculating-hessians-of-loss-w-r-t-parameters-of-a-system-of-odes/99025/1 "2023-05-17T23:31:57Z")

</div>

I have a system of ~10 ODEs with ~20 parameters and a loss function (e.g. MSE) that is evaluated on the trace of the ODE solution. What’s an efficient way to calculate the Hessian matrix of the loss w.r.t the parameters? Is there an autodiff package that works with ODE solvers that allows second derivatives? Would appreciate a link to an example if possible!

---

<div class="post-metadata">

**Author:** ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)\
**Post date:** [May 18, 2023, 12:30am UTC](https://discourse.julialang.org/t/calculating-hessians-of-loss-w-r-t-parameters-of-a-system-of-odes/99025/2 "2023-05-18T00:30:09Z")

</div>

[https://docs.sciml.ai/SciMLSensitivity/dev/examples/ode/second\_order\_adjoints/](https://docs.sciml.ai/SciMLSensitivity/dev/examples/ode/second_order_adjoints/)
