SciML demos

I am going over some demos in SciML. Consider the code fragment found at
https://docs.sciml.ai/Overview/stable/showcase/missing_physics/#autocomplete

function predict(θ, X = Xₙ[:, 1], T = t)
    _prob = remake(prob_nn, u0 = X, tspan = (T[1], T[end]), p = θ)
    Array(solve(_prob, Vern7(), saveat = T,
                abstol = 1e-6, reltol = 1e-6))
end


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

I do not understand the call to predict(θ) in the loss function. For default arguments to work properly, shouldn’t the second and third arguments of predict follow a semi-colon? In other words, shouldn’t the function have the prototype:

function predict(θ; X = Xₙ[:, 1], T = t)

Thanks.

Positional arguments can also have default values:

julia> f(x, y = 1) = x + y
f (generic function with 2 methods)

julia> f(2)
3

julia> f(2, 4)
6
1 Like

Thanks. I guess the difference is that these arguments cannot have a key. Only the value must be specified.

I guess the difference is that these arguments cannot have a key. Only the value must be specified.

Correct. Positional arguments appear before the ;. Keyword arguments appear after the ;.

1 Like