Open ghost opened 2 years ago
I've adapted scenario 1 - 3 so it should be working in #48
Thaaaanks! How did you find the right format for the setup for this part? Is there documentation on this somewhere or do you just know it?
# Merge the parameters
p = (;δ = rand(rng), ude = p_nn)
p = ComponentVector{Float64}(p)
# Define the hybrid model
function ude_dynamics!(du,u, p, t, p_true)
û = U(u, p.ude, st_nn)[1] # Network prediction
du[1] = p_true[1]*u[1] + û[1]
# We assume a linear decay rate for the predator
du[2] = -p.δ*u[2] + û[2]
end
I've recently switched to Lux and setup some models in the past. NamedTuple
s and ComponentVector
s are really helpful in structuring the overall parameters and both are useable for AD.
Additionally, I found this tutorial to be most insightful. Since I do not need a specific state, I just drop the information.
A more general way would be something along the lines of
mutable struct LuxContainer
model
state
end
(c::LuxContainer)(x, p) = begin
out, state = c.model(x, p, c.state)
c.state = state
return out
end
Thanks, that's helpful. I guess I need to slow down and try to really work step by step through these tutorials instead of scanning for stuff that looks like it might fit. I feel like i'm missing the "why" some things work and others don't...
Incorrect predictions, again....
@RajDandekar