# Flux.gradient throws MethodError even though loss is evaluated just fine

**URL:** <https://discourse.julialang.org/t/flux-gradient-throws-methoderror-even-though-loss-is-evaluated-just-fine/79561>\
**Category:** New to Julia\
**Tags:** question, diffeq\
**Created:** [April 16, 2022, 3:15am UTC](https://discourse.julialang.org/t/flux-gradient-throws-methoderror-even-though-loss-is-evaluated-just-fine/79561 "2022-04-16T03:15:13Z")\
**Posts on this page:** 1\
**Showing post:** 4

<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:** [April 16, 2022, 12:01pm UTC](https://discourse.julialang.org/t/flux-gradient-throws-methoderror-even-though-loss-is-evaluated-just-fine/79561/4 "2022-04-16T12:01:29Z")

</div>

This is just the same question and answer as [Using Flux: gradient on DifferentialEquations: solve results in an error](https://discourse.julialang.org/t/using-flux-gradient-on-differentialequations-solve-results-in-an-error/79564) and [https://www.reddit.com/r/Julia/comments/u4qgxc/flux\_gradient\_cant\_differentiate\_a\_function/](https://www.reddit.com/r/Julia/comments/u4qgxc/flux_gradient_cant_differentiate_a_function/).

---

_[View the full topic](https://discourse.julialang.org/t/flux-gradient-throws-methoderror-even-though-loss-is-evaluated-just-fine/79561)._
