Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions NeuralNetwork/Examples/Utilities/NARX_Network.mo
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
within NeuralNetwork.Examples.Utilities;

block NARX_Network
// This represents a three layer neural network with a given time delay

extends NeuralNetwork.Networks.Interfaces.Network(u = layer_scale.u, y = layer_3.y);
extends NeuralNetwork.Networks.Interfaces.Network(
redeclare Modelica.Blocks.Interfaces.RealInput u[size(layer_1.u,1)],
redeclare Modelica.Blocks.Interfaces.RealOutput y[size(layer_3.y,1)]);

NeuralNetwork.Layer.Preprocessing.Scale layer_scale(
min = {
Expand Down Expand Up @@ -106,6 +107,9 @@ block NARX_Network
redeclare function f = NeuralNetwork.ActivationFunctions.Id
) annotation(Placement(transformation(origin = {92, 0}, extent = {{-30, -30}, {30, 30}})));
equation
connect( u, layer_scale.u);
connect( layer_3.y, y);

connect(layer_scale.y, layer_1.u) annotation(
Line(points = {{-74, 0}, {-52, 0}}, color = {0, 0, 127}, thickness = 0.5));
connect(layer_1.y, layer_2.u) annotation(
Expand Down
6 changes: 4 additions & 2 deletions NeuralNetwork/Examples/Utilities/SimpleNetwork.mo
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
within NeuralNetwork.Examples.Utilities;

block SimpleNetwork "Neural Network approximating y = u*u + 0.5*u - 2.0 on interval [-1,1]"
extends NeuralNetwork.Networks.Interfaces.SISO(final u = inputLayer.u[1], final y = outputLayer.y[1]);
extends NeuralNetwork.Networks.Interfaces.SISO;
Layer.Dense inputLayer(
weights = layer_1_weights,
bias = layer_1_bias,
Expand All @@ -20,6 +19,9 @@ block SimpleNetwork "Neural Network approximating y = u*u + 0.5*u - 2.0 on inter
parameter Real[1,2] layer_2_weights = {{-4.513856227908402, 2.4932885356708683}};
parameter Real[1] layer_2_bias = {3.897109323824147};
equation
connect( u, inputLayer.u[1]);
connect( outputLayer.y[1], y);

connect(inputLayer.y, outputLayer.u) annotation(
Line(points = {{-48, 0}, {30, 0}}, color = {0, 0, 127}, thickness = 0.5));
annotation(
Expand Down
3 changes: 1 addition & 2 deletions NeuralNetwork/Layer/Interfaces/Layer.mo
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
within NeuralNetwork.Layer.Interfaces;

partial model Layer
partial block Layer
// Topology of the neural network
parameter Integer numInputs "Specification of the inputs of the layer";
parameter Integer numNeurons "Number of neurons in the layer";
Expand Down