From fd1c267bd996563574fe730ab9002614964d1df1 Mon Sep 17 00:00:00 2001 From: phannebohm Date: Fri, 24 Jan 2025 16:34:57 +0100 Subject: [PATCH] Update Example weights Better parameters based on dynamic optimization. Co-authored-by: linuslangenkamp <91832999+linuslangenkamp@users.noreply.github.com> --- NeuralNetwork/Examples/HelloWorld.mo | 1 + NeuralNetwork/Examples/Utilities/SimpleNetwork.mo | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/NeuralNetwork/Examples/HelloWorld.mo b/NeuralNetwork/Examples/HelloWorld.mo index 5303c5c..45f1199 100644 --- a/NeuralNetwork/Examples/HelloWorld.mo +++ b/NeuralNetwork/Examples/HelloWorld.mo @@ -10,6 +10,7 @@ model HelloWorld Placement(transformation(origin = {40, -30}, extent = {{-20, -20}, {20, 20}}))); Real reference = eq.y; Real prediction = nn.y; + Real error = reference - prediction; equation connect(sine.y, eq.u) annotation( Line(points = {{-38, 0}, {-20, 0}, {-20, 30}, {16, 30}}, color = {0, 0, 127})); diff --git a/NeuralNetwork/Examples/Utilities/SimpleNetwork.mo b/NeuralNetwork/Examples/Utilities/SimpleNetwork.mo index 1572450..d5c9ff1 100644 --- a/NeuralNetwork/Examples/Utilities/SimpleNetwork.mo +++ b/NeuralNetwork/Examples/Utilities/SimpleNetwork.mo @@ -15,10 +15,10 @@ block SimpleNetwork "Neural Network approximating y = u*u + 0.5*u - 2.0 on inter ) annotation( Placement(transformation(origin = {50, 0}, extent = {{-30, -30}, {30, 30}}))); - parameter Real[2,1] layer_1_weights = {{-0.95248}, {-0.943175}}; - parameter Real[2] layer_1_bias = {0.872633, -0.949252}; - parameter Real[1,2] layer_2_weights = {{-2.25385, 1.40389}}; - parameter Real[1] layer_2_bias = {0.60548}; + parameter Real[2,1] layer_1_weights = {{-0.7039596170222842}, {-0.8750912730224503}}; + parameter Real[2] layer_1_bias = {1.169784394444224, -1.344723440170712}; + parameter Real[1,2] layer_2_weights = {{-4.513856227908402, 2.4932885356708683}}; + parameter Real[1] layer_2_bias = {3.897109323824147}; equation connect(inputLayer.y, outputLayer.u) annotation( Line(points = {{-48, 0}, {30, 0}}, color = {0, 0, 127}, thickness = 0.5));