-
Notifications
You must be signed in to change notification settings - Fork 214
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Optimization with (L)BFGS gives DimensionMismatch(“dimensions must match”) #1011
Comments
You're missing a check for |
thank you very much! A beginners fault apparently. Closing the issue then |
An addition: It might be good to adapt documentation/examples to always account for this special case respectively. Here one updated example from the original UDE paper https://github.com/ChrisRackauckas/universal_differential_equations/blob/master/LotkaVolterra/scenario_2.jl#L104-L124 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,
sensealg = ForwardDiffSensitivity()
))
end
# Multiple shooting like loss
function loss(θ)
# Start with a regularization on the network
l = convert(eltype(θ), 1e-3)*sum(abs2, θ[2:end]) ./ length(θ[2:end])
for i in 1:size(XS,1)
X̂ = predict(θ, [XS[i,1], YS[i,1]], TS[i, :])
# Full prediction in x
l += sum(abs2, XS[i,:] .- X̂[1,:])
# Add the boundary condition in y
l += abs(YS[i, 2] .- X̂[2, end])
end
return l
end If I understand it correctly, this does not account for |
Indeed we should always add it to the examples, regardless if the defaults tend to diverge or not. |
errors with
The problem already exists for more than 3 years - it was first reported in https://discourse.julialang.org/t/optimization-with-lbfgs-gives-dimensionmismatch-dimensions-must-match/22167 but apparently never raised enough to get fixed.
It would be really great if this can be fixed.
The text was updated successfully, but these errors were encountered: