# Gradient of loss function from ODE solution

**URL:** <https://discourse.julialang.org/t/gradient-of-loss-function-from-ode-solution/113910>\
**Category:** General Usage\
**Tags:** question, autodiff\
**Created:** [May 6, 2024, 2:29pm UTC](https://discourse.julialang.org/t/gradient-of-loss-function-from-ode-solution/113910 "2024-05-06T14:29:36Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![Enrico\_Camporeale](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/enrico_camporeale/32/206102_2.png) [@Enrico\_Camporeale](https://discourse.julialang.org/u/Enrico_Camporeale)\
**Post date:** [May 7, 2024, 8:53am UTC](https://discourse.julialang.org/t/gradient-of-loss-function-from-ode-solution/113910/2 "2024-05-07T08:53:56Z")

</div>

@ChrisRackauckas Could you please give a look at this whenever you got the chance? It should be really straightforward and I have tried to follow your example here (just a slightly more complicated ODE)

> [@Correcting ODE initial conditions using automatic differentiation](https://discourse.julialang.org/t/correcting-ode-initial-conditions-using-automatic-differentiation/66018):
>
> Hi all, I’m trying to find a way to correct initial conditions of a system of ODEs by using automatic differentiation through the ODE solver. I have implemented a similar algorithm in Python using [TorchDIffEq](https://github.com/rtqichen/torchdiffeq) but I’m new to Julia and having trouble debugging the errors. I’ve gone through the docs and examples of both Zygote and ReverseDiff (which I think are best suited to my purpose) but I’m having difficulty adapting them to my problem. What I want to do is first solve the system of ODEs with…

Something is obviously escaping me 🙂  
Many thanks!

---

_[View the full topic](https://discourse.julialang.org/t/gradient-of-loss-function-from-ode-solution/113910)._
