Hello,

I’m trying to reproduce chemical reaction equations using neural ODE system. I calculated time-series of mass fraction of chemical species and temperature using other ODE solver, and exported the solution data to CSV file. Then, the solution data in CSV file was imported to the neural ODE program as training data. The neural ODE program I used is described as follow. The program is based on the code in the website (https://julialang.org/blog/2019/01/fluxdiffeq).

```
using Flux, DiffEqFlux, DifferentialEquations, Plots, CSV
# Read CSV file
flamedata = CSV.read("./results.csv")
flamedata2 = flamedata[2:2:6002,:]
u0 = Float32[0.; 0.11189834407236525]
datasize = 3001
tspan = (0.0f0,0.0003f0)
#tspan = (0.0f0,1.0f0)
t = range(tspan[1],tspan[2],length=datasize)
ode_data = Matrix(flamedata2[[:1,:4]])
ode_data = transpose(ode_data)
ode_data = convert(Array{Float32}, ode_data)
ode_data[1,:] = tanh.(ode_data[1,:]*100)
dudt = Chain(
#x -> -tanh.(x*10),
Dense(2,100,relu),
Dense(100,100,relu),
Dense(100,100,relu),
#Dense(30,30,relu),
#Dense(100,200,relu),
Dense(100,2)
)
ps = Flux.params(dudt)
n_ode = x->neural_ode(dudt,x,tspan,BS3(),saveat=t,dtmin=1.0E-14,maxiters=1e10,reltol=1e-7,abstol=1e-9)
function predict_n_ode()
n_ode(u0)
end
loss_n_ode() = sum(abs2,ode_data .- predict_n_ode())
data = Iterators.repeated((), 100000)
opt = ADAM(0.001, (0.9, 0.999))
cb = function () #callback function to observe training
display(loss_n_ode())
# plot current prediction against data
cur_pred = Flux.data(predict_n_ode())
pl1 = plot(t,ode_data[1,:],label="data1",lw=2)
plot!(pl1,t,cur_pred[1,:],label="prediction1",lw=2)
plot!(pl1,t,ode_data[2,:],label="data2",lw=2)
plot!(pl1,t,cur_pred[2,:],label="prediction2",lw=2)
gui(plot(pl1))
end
# Display the ODE with the initial parameter values.
cb()
Flux.train!(loss_n_ode, ps, data, opt, cb = cb)
```

The attached figure shows comparison between original ODE solution and neural ODE solution. “data2” is mass fraction of hydrogen and “data1” is just reference data to make solution set at each time steps unique combination. The line of “prediction2” was getting closer to “data2” line in the simulation. However, the solution from the neural ODE system could not reproduce sharp gradient change at 1.6E-4 seconds.

Could you give me advice for how to tune parameters in the neural ODE program to get more closer solution?