Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Docs: https://docs.sciml.ai/DiffEqFlux/dev/examples/multiple_shooting/

In Multiple Shooting, the training data is split into overlapping intervals. The solver (OptimizationPolyalgorithms.PolyOpt()) is trained on individual intervals. The results are stiched together.

This simple method assumes no noise in the data. A more robust version can be found at JuliaSimModelOptimizer.jl, which is a proprietary software.

Random.Xoshiro(0xdb2fa90498613fdf, 0x48d73dc42d195740, 0x8c49bc52dc8a77ea, 0x1911b814c02405e8, 0x22a21880af5dc689)

Define initial conditions and time steps

0.0f0:0.1f0:5.0f0

Generate data from the true function: x3∗Ax^3 * A

┌ Warning: Verbosity toggle: dt_epsilon 
│  Initial timestep too small (near machine epsilon), using default: dt = 1.0e-6
└ @ OrdinaryDiffEqCore ~/.julia/packages/OrdinaryDiffEqCore/ICc50/src/initdt.jl:222
2×51 Matrix{Float32}: 2.0 1.76453 0.66682 -0.58055 … 0.0658094 -0.102812 -0.266609 0.0 1.4286 1.86579 1.80632 0.948874 0.940418 0.930742

Define the Neural Network using Lux.jl

(Float32[-1.8019577, -0.18273845, 1.677652, 0.19449931, 0.7557112, 1.1159611, -1.581186, 1.7986798, -0.36156967, -1.9202054 … 0.35582402, -0.29064924, 0.32653868, 0.36876014, -0.35387143, 0.12959939, 0.25605455, -0.20957911, 0.10817152, -0.20544955], (Axis(layer_1 = ViewAxis(1:0, Shaped1DAxis((0,))), layer_2 = ViewAxis(1:48, Axis(weight = ViewAxis(1:32, ShapedAxis((16, 2))), bias = ViewAxis(33:48, Shaped1DAxis((16,))))), layer_3 = ViewAxis(49:82, Axis(weight = ViewAxis(1:32, ShapedAxis((2, 16))), bias = ViewAxis(33:34, Shaped1DAxis((2,)))))),))

Define the NeuralODE problem

ODEProblem with uType Vector{Float32} and tType Float32. In-place: false Non-trivial mass matrix: false timespan: (0.0f0, 5.0f0) u0: 2-element Vector{Float32}: 2.0 0.0

Parameters for Multiple Shooting

loss_multiple_shooting (generic function with 1 method)

Animate training process in the callback function

#10 (generic function with 1 method)

Solve the problem using OptimizationPolyalgorithms.PolyOpt().

128.055394 seconds (403.87 M allocations: 24.860 GiB, 4.76% gc time, 63.46% compilation time: 4% of which was recompilation)
Loss is 9.923296

Loss over epochs

Plot{Plots.GRBackend() n=1}

Visualize the fitting processes

[ Info: Saved animation to /tmp/jl_GxM5IjChS3.mp4
Loading...

This notebook was generated using Literate.jl.