Hi, I’m trying to create a NeuralODE for the forcasting of a dynamic system.
I did a NN for the forcasting of the system under different initial conditions and it’s work very well.
Now I would like to create NN capable to learn the infuences of a possible variation of a input value, to do that I’m trying to incorporate in the first layer of the NN a customized layer that take cares of the dynamic of the system I want to reproduce.
The problem is that I don’t understand how can I bring the parameters of this custom layer together with the other parameters of the whole NN.
function law(u,p,t)
F = Float32(5.0)
α = p
z1 = u[2]
z2 = α*F .- u[2] - u[1]
return[z1,z2]
end
#nn
NN = Lux.Chain(x -> law(x,p,t),
Lux.Dense(2,20,tanh),
Lux.Dense(30,10,tanh),
Lux.Dense(10,2))
p, st = Lux.setup(rng, NN)
prob_neuralode = NeuralODE(NN, tspan, Tsit5(), saveat = t)
p_init = Lux.ComponentArray(p)
the output is always an empty first layer
ComponentVector{Float32}(layer_1 = Float32[], layer_2 = (weight = Float32[0.567042 0.4250619; 0.042177025 0.5778097; … ; -0.30559936 -0.09352723; 0.20134257 -0.40837312], bias = Float32[0.0; 0.0; … ; 0.0; 0.0]), layer_3 = (weight = Float32[-0.1402396 0.52604 … -0.17828122 0.22984686; -0.20939533 0.24967496 … 0.2779108 -0.4940759; … ; -0.44822726 0.3582243 … -0.25572324 -0.05863302; 0.43971282 0.09462769 … -0.12614584 -0.41752148], bias = Float32[0.0; 0.0; … ; 0.0; 0.0]), layer_4 = (weight = Float32[0.36662766 0.41478822 … -0.37065506 -0.43711254; -0.15670164 -0.54979855 … -0.58355767 0.009892202], bias = Float32[0.0; 0.0]))