# Questions about the DiffEqFlux multiple shooting example

**URL:** <https://discourse.julialang.org/t/questions-about-the-diffeqflux-multiple-shooting-example/129418>\
**Category:** Machine Learning\
**Tags:** diffeqflux\
**Created:** [May 28, 2025, 6:58pm UTC](https://discourse.julialang.org/t/questions-about-the-diffeqflux-multiple-shooting-example/129418 "2025-05-28T18:58:42Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![julianewbsourcream](https://avatars.discourse-cdn.com/v4/letter/j/7ea924/32.png) [@julianewbsourcream](https://discourse.julialang.org/u/julianewbsourcream)\
**Post date:** [May 28, 2025, 6:58pm UTC](https://discourse.julialang.org/t/questions-about-the-diffeqflux-multiple-shooting-example/129418/1 "2025-05-28T18:58:42Z")

</div>

Hi,  
I am training a neural ODE on a periodic function and wanted to try out `DiffEqFlux.multiple_shoot()`. After reviewing the online example @ docs.sciml.ai/DiffEqFlux/stable/examples/multiple\_shooting/, I was hoping someone could answer a couple of basic questions for me. The questions are:

1. Why was the `ComponentArray` `p_init` separated into its data and axes? Why not just provide a `ComponentArray` to `OptimizationProblem()` which would be used by `loss_multiple_shooting()` directly?

```julia
ps = ComponentArray(p_init)
pd, pax = getdata(ps), getaxes(ps)
...

function loss_multiple_shooting(p)
    ps = ComponentArray(p, pax)
...
end

optprob = Optimization.OptimizationProblem(optf, pd)

```

1. It looks like `neuralode` was created but never used. Is this intentional?
2. Inside the callback function, why is a global variable used to track the iteration number? Couldn’t you use `state.iter` if state is an `OptimizationState` object ?
3. Up to now, I have been using the Lux training API to train my models. Is there a version of multiple shooting or some similar training scheme implemented in Lux?

Thanks in advance for your help.

---

<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:** [May 29, 2025, 12:18am UTC](https://discourse.julialang.org/t/questions-about-the-diffeqflux-multiple-shooting-example/129418/2 "2025-05-29T00:18:13Z")

</div>

I think the tl;dr is that this tutorial needs an update.

> [@julianewbsourcream](#):
>
> Why was the `ComponentArray` `p_init` separated into its data and axes? Why not just provide a `ComponentArray` to `OptimizationProblem()` which would be used by `loss_multiple_shooting()` directly?

The tutorial is just old, it should just work using the componentarray

> [@julianewbsourcream](#):
>
> - It looks like `neuralode` was created but never used. Is this intentional?

No we should update the tutorial.

> [@julianewbsourcream](#):
>
> - Inside the callback function, why is a global variable used to track the iteration number? Couldn’t you use `state.iter` if state is an `OptimizationState` object ?

Yes, this tutorial was just written before that existed, so it’s another sign this tutorial needs an update.

> [@julianewbsourcream](#):
>
> 1. Up to now, I have been using the Lux training API to train my models. Is there a version of multiple shooting or some similar training scheme implemented in Lux?

If you grab the `optprob.f` you can use it in the Lux training API.

---

<div class="post-metadata">

**Author:** ![julianewbsourcream](https://avatars.discourse-cdn.com/v4/letter/j/7ea924/32.png) [@julianewbsourcream](https://discourse.julialang.org/u/julianewbsourcream)\
**Post date:** [May 29, 2025, 2:04pm UTC](https://discourse.julialang.org/t/questions-about-the-diffeqflux-multiple-shooting-example/129418/3 "2025-05-29T14:04:04Z")

</div>

@ChrisRackauckas - Thank you for the reply.

> [@julianewbsourcream](#):
>
> 1. Up to now, I have been using the Lux training API to train my models. Is there a version of multiple shooting or some similar training scheme implemented in Lux?
> 
> If you grab the `optprob.f` you can use it in the Lux training API.

That is really cool. Thanks for pointing this out.

Out of curiosity, can people contribute updates to the tutorials on GitHub?

---

<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:** [May 30, 2025, 8:25am UTC](https://discourse.julialang.org/t/questions-about-the-diffeqflux-multiple-shooting-example/129418/4 "2025-05-30T08:25:24Z")

</div>

> [@julianewbsourcream](#):
>
> Out of curiosity, can people contribute updates to the tutorials on GitHub?

Yes

 ![Screenshot 2025-05-30 082405](https://global.discourse-cdn.com/julialang/original/3X/0/d/0d6dff8064b98617185a90e590160613bc410ca4.png)

There’s an edit button up there which brings you to the .md file:

> <https://github.com/SciML/DiffEqFlux.jl/blob/master/docs/src/examples/multiple_shooting.md>

the docs are all generated from the Documenter.jl .md files. So if you make a pull request to change those the docs will get updated based on the code in there.

The Documenter.jl docs explain the syntax on the .md files:

> **[Home · Documenter.jl](https://documenter.juliadocs.org/stable/)**
>
> Documentation for Documenter.jl.

---

<div class="post-metadata">

**Author:** ![julianewbsourcream](https://avatars.discourse-cdn.com/v4/letter/j/7ea924/32.png) [@julianewbsourcream](https://discourse.julialang.org/u/julianewbsourcream)\
**Post date:** [June 2, 2025, 5:17pm UTC](https://discourse.julialang.org/t/questions-about-the-diffeqflux-multiple-shooting-example/129418/5 "2025-06-02T17:17:28Z")

</div>

@ChrisRackauckas - Amazing. Thank you for the detailed response. I will give the update a try.
