# DiffEqFlux: how do declare a system of ODE which is backpropagatable?

**URL:** <https://discourse.julialang.org/t/diffeqflux-how-do-declare-a-system-of-ode-which-is-backpropagatable/21254>\
**Category:** Machine Learning\
**Tags:** diffeq\
**Created:** [February 27, 2019, 8:21am UTC](https://discourse.julialang.org/t/diffeqflux-how-do-declare-a-system-of-ode-which-is-backpropagatable/21254 "2019-02-27T08:21:41Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![pochoi](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pochoi/32/3742_2.png) [@pochoi](https://discourse.julialang.org/u/pochoi)\
**Post date:** [February 27, 2019, 8:21am UTC](https://discourse.julialang.org/t/diffeqflux-how-do-declare-a-system-of-ode-which-is-backpropagatable/21254/1 "2019-02-27T08:21:41Z")

</div>

Here is a simple example.  
Flux’s parameter seems to be not so friendly with matrix multiplication.  
When doing `p .* A` where p is a parameter and A is a matrix, things go bad…

```julia
using DifferentialEquations
using Flux, DiffEqFlux

function myode(du,u,p,t)
  p1, p2 = p
  A1 = [0.0 1.0; 0.0 0.0]
  A2 = [0.0 0.0; 1.0 0.0]
  du .= p1 .* (A1*u) + p2 .* (A2*u)
end

u0 = [1.0, -1.0]
tspan = (0.0,1.0)
p = [1.0, 2.0]
prob = ODEProblem(myode,u0,tspan,p)

p = param([1.0, 2.0])
params = Flux.Params([p])
diffeq_rd(p, prob, Tsit5())

```

I got the following error

```julia
Not implemented: convert tracked Flux.Tracker.TrackedReal{Float64} to tracked Float64

```

I would be appreciate any tips on getting around this issue!

---

<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:** [February 27, 2019, 12:55pm UTC](https://discourse.julialang.org/t/diffeqflux-how-do-declare-a-system-of-ode-which-is-backpropagatable/21254/2 "2019-02-27T12:55:06Z")

</div>

What call is causing the error?

---

<div class="post-metadata">

**Author:** ![pochoi](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pochoi/32/3742_2.png) [@pochoi](https://discourse.julialang.org/u/pochoi)\
**Post date:** [February 28, 2019, 5:58am UTC](https://discourse.julialang.org/t/diffeqflux-how-do-declare-a-system-of-ode-which-is-backpropagatable/21254/3 "2019-02-28T05:58:38Z")

</div>

Thank you so much!

I figure it out that I should use `.+` instead of `+` to keep the sum to be trackable. I should write in the ode function:

```julia
p1 .* (A1*u) .+ p2 .* (A2*u)

```
