You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, currently I am trying to use NeuraDAE() and I try to run the neural_dae_tests.jl as a reference.
However, I got some errors when I run the test code
using ComponentArrays, Zygote, Optimization, OptimizationOptimJL, OrdinaryDiffEq, Random, Lux, DiffEqFlux
# A desired MWE for now, not a test yet.
function rober(du, u, p, t)
y₁, y₂, y₃ = u
k₁, k₂, k₃ = p
du[1] = -k₁ * y₁ + k₃ * y₂ * y₃
du[2] = k₁ * y₁ - k₃ * y₂ * y₃ - k₂ * y₂^2
du[3] = y₁ + y₂ + y₃ - 1
nothing
end
M = [1.0 0 0
0 1.0 0
0 0 0]
prob_mm = ODEProblem(ODEFunction(rober; mass_matrix = M), [1.0, 0.0, 0.0], (0.0, 10.0), (0.04, 3e7, 1e4))
sol = solve(prob_mm, Rodas5(); reltol = 1e-8, abstol = 1e-8)
dudt2 = Chain(x -> x .^ 3, Dense(6, 50, tanh), Dense(50, 3))
u₀ = [1.0, 0, 0]
du₀ = [-0.04, 0.04, 0.0]
tspan = (0.0, 10.0)
ndae = NeuralDAE(dudt2, (u, p, t) -> [u[1] + u[2] + u[3] - 1], tspan,
DFBDF(); differential_vars = [true, true, false])
ps, st = Lux.setup(Xoshiro(0), ndae)
ps = ComponentArray(ps)
predict_n_dae(p) = first(ndae((u₀, du₀), p, st))
function loss(p)
pred = predict_n_dae(p)
loss = sum(abs2, sol .- pred)
return loss, pred
end
begin
optfunc = Optimization.OptimizationFunction((x, p) -> loss(x), Optimization.AutoZygote())
optprob = Optimization.OptimizationProblem(optfunc, ps)
res = Optimization.solve(optprob, BFGS(; initial_stepnorm = 0.0001))
end
By the way, I have tried to change BFGS to DFBDF but got different error:
ERROR: Optimization algorithm not found. Either the chosen algorithm is not a valid solver
choice for the `OptimizationProblem`, or the Optimization solver library is not loaded.
Make sure that you have loaded an appropriate Optimization.jl solver library, for example,
`solve(prob,Optim.BFGS())` requires `using OptimizationOptimJL` and
`solve(prob,Adam())` requires `using OptimizationOptimisers`.
For more information, see the Optimization.jl documentation: https://docs.sciml.ai/Optimization/stable/.
Chosen Optimizer: DFBDF{5, 0, true, Nothing, NLNewton{Rational{Int64}, Rational{Int64}, Rational{Int64}, Rational{Int64}}, typeof(OrdinaryDiffEq.DEFAULT_PRECS), Val{:forward}, true, nothing, Nothing, Nothing}(Val{5}(), nothing, NLNewton{Rational{Int64}, Rational{Int64}, Rational{Int64}, Rational{Int64}}(1//100, 10, 1//5, 1//5, false, true, 0//1),
OrdinaryDiffEq.DEFAULT_PRECS, nothing, nothing, :linear, :Standard)
Stacktrace:
[1] __solve(::OptimizationProblem{…}, ::DFBDF{…}; kwargs::@Kwargs{})
@ SciMLBase C:\.julia\packages\SciMLBase\NjslX\src\solve.jl:193
[2] __solve(::OptimizationProblem{…}, ::DFBDF{…})
@ SciMLBase C:\.julia\packages\SciMLBase\NjslX\src\solve.jl:192
[3] solve(::OptimizationProblem{…}, ::DFBDF{…}; kwargs::@Kwargs{})
@ SciMLBase C:\.julia\packages\SciMLBase\NjslX\src\solve.jl:99
[4] solve(::OptimizationProblem{…}, ::DFBDF{…})
@ SciMLBase C:\.julia\packages\SciMLBase\NjslX\src\solve.jl:93
[5] top-level scope
@ d:\julia_neuralDAE.jl:102
The text was updated successfully, but these errors were encountered:
Hi, currently I am trying to use NeuraDAE() and I try to run the neural_dae_tests.jl as a reference.
However, I got some errors when I run the test code
Running this code, I got:
The full stack in this link
By the way, I have tried to change
BFGS
toDFBDF
but got different error:The text was updated successfully, but these errors were encountered: