# Provide parameters and user-defined functions to neural\_ode in DiffEqFlux.jl

**URL:** <https://discourse.julialang.org/t/provide-parameters-and-user-defined-functions-to-neural-ode-in-diffeqflux-jl/21184>\
**Category:** General Usage\
**Tags:** diffeq, flux\
**Created:** [February 25, 2019, 8:05pm UTC](https://discourse.julialang.org/t/provide-parameters-and-user-defined-functions-to-neural-ode-in-diffeqflux-jl/21184 "2019-02-25T20:05:13Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![mleprovost](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mleprovost/32/7166_2.png) [@mleprovost](https://discourse.julialang.org/u/mleprovost)\
**Post date:** [February 25, 2019, 8:05pm UTC](https://discourse.julialang.org/t/provide-parameters-and-user-defined-functions-to-neural-ode-in-diffeqflux-jl/21184/1 "2019-02-25T20:05:13Z")

</div>

Hello,

First, I would like to thanks the developers of DiffEqFlux.jl, this is an amazing work!

I want to use the function `neural_ode` to model the right-hand side of an ODE for transport of a particle :  
\frac{dx}{dt} = F( V(x), p)   
where V is a given field of space and F a nonlinear function of the inputs V(x) and p some parameters of the particle (these parameters shouldn’t be optimized)

I don’t know how to provide these nonlearnable parameters to `neural_ode`

Below is what I want to do:

```julia
using DifferentialEquations
using Flux, DiffEqFlux

u0 = 1.0f0
V = x -> cos(x)

# 0.5 is a parameter of the particle
Input = [u0, V, 0.5f0]

dudt = Chain(y -> vcat(p[2](y), p[3]), 
             Dense(2,1,relu),
             Dense(1,1))

tspan = (0.0f0, 2.0f0)
n_ode = x-> neural_ode(dudt, x[1], tspan, ABM54(),
    dt = 0.05f0, adpative = false, p = x[2:3])

Input
3-element Array{Any,1}:
 1.0f0                               
  getfield(Main, Symbol("##25#26"))()
 0.5f0                      

n_ode(Input)
MethodError: no method matching similar(::Float32)
Closest candidates are:
  similar(!Matched::ZMQ.Message, !Matched::Type{T}, !Matched::Tuple{Vararg{Int64,N}} where N) where T at /u/home/m/mleprovo/.julia/packages/ZMQ/ABGOx/src/message.jl:93
  similar(!Matched::DataStructures.IntSet) at deprecated.jl:53
  similar(!Matched::Sundials.NVector) at /u/home/m/mleprovo/.julia/packages/Sundials/KYRgQ/src/nvector_wrapper.jl:69
  ...

Stacktrace:
 [1] alg_cache(::ABM54, ::Float32, ::Float32, ::Type, ::Type, ::Type, ::Float32, ::Float32, ::ODEFunction{true,getfield(DiffEqFlux, Symbol("#dudt_#24")){Chain{Tuple{getfield(Main, Symbol("##27#28")),Dense{typeof(relu),TrackedArray{…,Array{Float32,2}},TrackedArray{…,Array{Float32,1}}},Dense{typeof(identity),TrackedArray{…,Array{Float32,2}},TrackedArray{…,Array{Float32,1}}}}}},LinearAlgebra.UniformScaling{Bool},Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing}, ::Float32, ::Float32, ::Float32, ::Array{Float32,1}, ::Bool, ::Type{Val{true}}) at /u/home/m/mleprovo/.julia/packages/OrdinaryDiffEq/HJOah/src/caches/adams_bashforth_moulton_caches.jl:244

```

---

<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 25, 2019, 8:45pm UTC](https://discourse.julialang.org/t/provide-parameters-and-user-defined-functions-to-neural-ode-in-diffeqflux-jl/21184/2 "2019-02-25T20:45:42Z")

</div>

The solution is more generally [How to mix "normal" ODEs and Neuronal ODEs? · Issue #15 · SciML/DiffEqFlux.jl · GitHub](https://github.com/JuliaDiffEq/DiffEqFlux.jl/issues/15) which we are currently working on.
