# Continue solving ODE problem when using NeuralPDE.NNODE

**URL:** <https://discourse.julialang.org/t/continue-solving-ode-problem-when-using-neuralpde-nnode/101580>\
**Category:** General Usage\
**Tags:** question, ode, neural-network\
**Created:** [July 13, 2023, 4:09pm UTC](https://discourse.julialang.org/t/continue-solving-ode-problem-when-using-neuralpde-nnode/101580 "2023-07-13T16:09:00Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ethan\_Tran](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ethan_tran/32/49198_2.png) [@Ethan\_Tran](https://discourse.julialang.org/u/Ethan_Tran)\
**Post date:** [July 13, 2023, 4:09pm UTC](https://discourse.julialang.org/t/continue-solving-ode-problem-when-using-neuralpde-nnode/101580/1 "2023-07-13T16:09:01Z")

</div>

I tried to continue solving by using the previous weight as the initial weight for the new one. But the loss for the first iteration of the new one is higher than the final loss of the previous one.  
My code is below:

```julia
using NeuralPDE, Lux, OptimizationOptimisers
SIMB_NN(u,p,t) = [u[2], 5- 10*sin(u[1])-1.7*u[2]]
prob = ODEProblem(SIMB_NN, u0, tspan)
chain = Lux.Chain(Dense(1,5,Lux.σ), Dense(5,2))
opt = OptimizationOptimisers.Adam(0.1)
sol = solve(prob, NeuralPDE.NNODE(chain,opt), verbose = true, dt = 0.01f0, abstol=1e-10, maxiters = 200)

```

the loss for the first time solving:

```julia
Current loss is: 2295.899122938303, Iteration: 198
Current loss is: 2287.8828325994946, Iteration: 199
Current loss is: 2281.6355418052744, Iteration: 200
Current loss is: 2281.6355418052744, Iteration: 201

```

then I continue solving follow:  
`sol = solve(prob, NeuralPDE.NNODE(chain,opt,init_params = sol.k), verbose = true, dt = 0.01f0, abstol=1e-10, maxiters = 200)`  
However, the loss of the new one is:

```julia
Current loss is: 10131.155170881239, Iteration: 1
Current loss is: 8778.128648065542, Iteration: 2
Current loss is: 7562.72487697895, Iteration: 3
Current loss is: 6747.883320241421, Iteration: 4
Current loss is: 6407.502788917461, Iteration: 5

```

There is any way to continue solving the ODE problem from the end of the previous solve?

---

<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 7, 2024, 12:39pm UTC](https://discourse.julialang.org/t/continue-solving-ode-problem-when-using-neuralpde-nnode/101580/2 "2024-04-07T12:39:14Z")

</div>

With [Tag the original solution to sol.original and simplify dependencies by ChrisRackauckas · Pull Request #846 · SciML/NeuralPDE.jl · GitHub](https://github.com/SciML/NeuralPDE.jl/pull/846), sol.original returns the internal optimization, so `sol.original.u` would be the parameters of the optimization. You could use that to seed the next optimization at the same parameters as the current.

---

<div class="post-metadata">

**Author:** ![Ethan\_Tran](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ethan_tran/32/49198_2.png) [@Ethan\_Tran](https://discourse.julialang.org/u/Ethan_Tran)\
**Post date:** [April 7, 2024, 5:12pm UTC](https://discourse.julialang.org/t/continue-solving-ode-problem-when-using-neuralpde-nnode/101580/3 "2024-04-07T17:12:27Z")

</div>

Thank you for your information. I really appreciate your time
