Skip to content

Commit cbb2c60

Browse files
Missing name in NueralNetworkBlock
This needs to be corrected in the tutorial as well, it needs to use `@named` in its instantiation in order to correctly name the block. Right now it's always named `ude_comp` which will lead to subtle bugs.
1 parent 2d6db67 commit cbb2c60

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/ModelingToolkitNeuralNets.jl

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ include("utils.jl")
1717
chain = multi_layer_feed_forward(n_input, n_output),
1818
rng = Xoshiro(0),
1919
init_params = Lux.initialparameters(rng, chain),
20-
eltype = Float64)
20+
eltype = Float64,
21+
name)
2122
2223
Create an `ODESystem` with a neural network inside.
2324
"""
@@ -26,7 +27,8 @@ function NeuralNetworkBlock(n_input = 1,
2627
chain = multi_layer_feed_forward(n_input, n_output),
2728
rng = Xoshiro(0),
2829
init_params = Lux.initialparameters(rng, chain),
29-
eltype = Float64)
30+
eltype = Float64,
31+
name)
3032
ca = ComponentArray{eltype}(init_params)
3133

3234
@parameters p[1:length(ca)] = Vector(ca)
@@ -39,8 +41,8 @@ function NeuralNetworkBlock(n_input = 1,
3941

4042
eqs = [output.u ~ out]
4143

42-
@named ude_comp = ODESystem(
43-
eqs, t_nounits, [], [p, T], systems = [input, output])
44+
ude_comp = ODESystem(
45+
eqs, t_nounits, [], [p, T]; systems = [input, output], name)
4446
return ude_comp
4547
end
4648

0 commit comments

Comments
 (0)