UDE example missing physics MethodError

Hello all, some time ago I reproduced the Automatically Discover Missing Physics by Embedding Machine Learning into Differential Equations · Overview of Julia's SciML example on my local machine for future projects. Some time has passed and I revisited the example to try it on my data. I now face an error that I was unable to solve for a few days. When I follow the example and run
res1 = Optimization.solve(optprob, OptimizationOptimisers.Adam(), callback = callback, maxiters = 5000)

I get the error (Julia 1.9.2):

julia> OptimizationProblem. In-place: true
u0: ComponentVector{Float64}(layer_1 = (weight = [0.49426865577697754 0.5692564249038696; 0.40171918272972107 -0.8665286302566528; … ; 0.47097498178482056 -0.7521204352378845; -0.20216092467308044 -0.3197280168533325], bias = [0.0; 0.0; … ; 0.0; 0.0;;]), layer_2 = (weight = [0.6822634935379028 -0.6952740550041199 … 0.5011160969734192 0.24313241243362427; -0.39863723516464233 -0.17176461219787598 … -0.6159946322441101 0.18968746066093445; … ; -0.7200708389282227 -0.6787673234939575 … -0.5633968114852905 0.1658746749162674; 0.0014851824380457401 -0.10373303294181824 … 0.09008530527353287 -0.043933477252721786], bias = [0.0; 0.0; … ; 0.0; 0.0;;]), layer_3 = (weight = [0.0011237671133130789 0.006483868230134249 … 0.2754976451396942 -0.2874394953250885; 0.04383227229118347 -0.32253962755203247 … 0.09472294896841049 -0.4210013747215271; … ; -0.5179172158241272 -0.6043259501457214 … -0.18625909090042114 0.06577149033546448; -0.2150842249393463 0.2565661072731018 … 0.5849692821502686 0.2193499207496643], bias = [0.0; 0.0; … ; 0.0; 0.0;;]), layer_4 = (weight = [0.7144760489463806 0.4398183226585388 … -0.8286120891571045 0.04256918653845787; -0.5670844316482544 -0.3962741494178772 … 0.1667986661195755 0.8446723818778992], bias = [0.0; 0.0;;]))
julia> ERROR: MethodError: no method matching (::var"#7#8")(::ComponentVector{Float64, Vector{Float64}, Tuple{Axis{(layer_1 = ViewAxis(1:15, Axis(weight = ViewAxis(1:10, ShapedAxis((5, 2))), bias = ViewAxis(11:15, ShapedAxis((5, 1))))), layer_2 = ViewAxis(16:45, Axis(weight = ViewAxis(1:25, ShapedAxis((5, 5))), bias = ViewAxis(26:30, ShapedAxis((5, 1))))), layer_3 = ViewAxis(46:75, Axis(weight = ViewAxis(1:25, ShapedAxis((5, 5))), bias = ViewAxis(26:30, ShapedAxis((5, 1))))), layer_4 = ViewAxis(76:87, Axis(weight = ViewAxis(1:10, ShapedAxis((2, 5))), bias = ViewAxis(11:12, ShapedAxis((2, 1))))))}}}, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64)

I tried Julia 1.10, 1.9.3, 1.9.2 and the GitHub example (SciMLDocs/docs/src/showcase/missing_physics.md at main · SciML/SciMLDocs · GitHub) that is slightly different from the https://docs.sciml.ai/ site with a similar result (Julia V1.10)

OptimizationProblem. In-place: true
u0: ComponentVector{Float64}(layer_1 = (weight = [0.49426865577697754 0.5692564249038696; 0.40171918272972107 -0.8665286302566528; … ; 0.47097498178482056 -0.7521204352378845; -0.20216092467308044 -0.3197280168533325], bias = [0.0; 0.0; … ; 0.0; 0.0;;]), layer_2 = (weight = [0.6822634935379028 -0.6952740550041199 … 0.5011160969734192 0.24313241243362427; -0.39863723516464233 -0.17176461219787598 … -0.6159946322441101 0.18968746066093445; … ; -0.7200708389282227 -0.6787673234939575 … -0.5633968114852905 0.1658746749162674; 0.0014851824380457401 -0.10373303294181824 … 0.09008530527353287 -0.043933477252721786], bias = [0.0; 0.0; … ; 0.0; 0.0;;]), layer_3 = (weight = [0.0011237671133130789 0.006483868230134249 … 0.2754976451396942 -0.2874394953250885; 0.04383227229118347 -0.32253962755203247 … 0.09472294896841049 -0.4210013747215271; … ; -0.5179172158241272 -0.6043259501457214 … -0.18625909090042114 0.06577149033546448; -0.2150842249393463 0.2565661072731018 … 0.5849692821502686 0.2193499207496643], bias = [0.0; 0.0; … ; 0.0; 0.0;;]), layer_4 = (weight = [0.7144760489463806 0.4398183226585388 … -0.8286120891571045 0.04256918653845787; -0.5670844316482544 -0.3962741494178772 … 0.1667986661195755 0.8446723818778992], bias = [0.0; 0.0;;]))

X̂ = [3.1463924566781167 4.5955199569418435 6.652429231054453 9.496485754742828 13.43242542961294 18.879880122099816 26.419324356194295 36.85414623135183 51.29625949571045 71.28458685089858 98.94904447005194 137.23750166488882 190.2298997989219 263.5730028647023 365.0821051482417 505.5738137929013 700.0186441479915 969.1362480387486 1341.603260071275 1857.1090196099185 2570.58478785412; 1.5423300037202512 0.8822823032679432 0.42409054140127733 0.13224904072371835 -0.053771975183326215 -0.17238301460067562 -0.24801275176485643 -0.2962364012635096 -0.3269851577443046 -0.3465914305379157 -0.35909294205886816 -0.36706425772793677 -0.3721469930055787 -0.3753878881303844 -0.37745437411337923 -0.3787720237432556 -0.379612194247756 -0.38014791062246533 -0.38048949846095037 -0.3807073044848721 -0.3808461837404308]
Xₙ = [3.1463924566781167 2.9789497209894984 2.6634060775666626 2.31933418589055 1.9699643139528655 1.7223328399065732 1.5852450728246326 1.522224326136266 1.5668456320709663 1.6383422570738027 1.7695223310418633 1.9511633109873703 2.2247478283486455 2.4979113975924907 2.7776823085477873 3.0213917630688063 3.149389398343688 3.089989479398331 2.900962968893112 2.560371957470157 2.177861137582955; 1.5423300037202512 1.818933039597584 2.0475449086216413 2.1471793355330604 2.091544400272018 1.9384758686342665 1.713909591119019 1.5039863536846394 1.293621826018874 1.1460540473730914 1.009176576579711 0.9329050714896047 0.9143746527350252 0.9416435765284963 1.0028435039095414 1.1466150067640632 1.3763776290092238 1.6282005572304008 1.9089543253751537 2.08787115660585 2.1438766332775456]
ERROR: MethodError: no method matching zero(::Type{ComponentVector{Float64, Vector{Float64}, Tuple{Axis{…}}}})

I am running out of combinations to try and lack Julia experience to figure it out on my own, therfore I kindly ask the Julia community to help me out, cheers and thanks in advance.

Okay, i figured it out, I wanted to see the variables of the loss function

function loss(θ)
    X̂ = predict(θ)
    @show X̂
    mean(abs2, Xₙ .- X̂)
    @show Xₙ
end

this breaks the code, don’t use @show inside of the loss function

function loss(θ)
    X̂ = predict(θ)
    mean(abs2, Xₙ .- X̂)
end

may this be of use to someone else in the future