-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make activation functions
replaceable
(#18)
- Loading branch information
1 parent
7f80aae
commit f0d1bf9
Showing
18 changed files
with
57 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
within NeuralNetwork.ActivationFunctions; | ||
|
||
partial function ActivationFunction "All activation functions extend from this partial function" | ||
extends Modelica.Icons.Function; | ||
input Real u "Input of the function"; | ||
output Real y "Output of the function"; | ||
end ActivationFunction; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
within NeuralNetwork.ActivationFunctions; | ||
|
||
function Id | ||
extends ActivationFunction; | ||
algorithm | ||
y := u; | ||
end Id; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,7 @@ | ||
within NeuralNetwork.ActivationFunctions; | ||
|
||
function ReLu | ||
extends Modelica.Icons.Function; | ||
input Real u "Input of the function"; | ||
output Real y "Output of the function"; | ||
extends ActivationFunction; | ||
algorithm | ||
y := max(0.0, u); | ||
end ReLu; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,7 @@ | ||
within NeuralNetwork.ActivationFunctions; | ||
|
||
function Sigmoid | ||
extends Modelica.Icons.Function; | ||
input Real u "Input of the function"; | ||
output Real y "Output of the function"; | ||
extends ActivationFunction; | ||
algorithm | ||
y := 1 / (1 + Modelica.Math.exp(-u)); | ||
y := 1 / (1 + exp(-u)); | ||
end Sigmoid; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
within NeuralNetwork.ActivationFunctions; | ||
|
||
function Softplus | ||
extends ActivationFunction; | ||
algorithm | ||
y := log(1 + exp(u)); | ||
end Softplus; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
within NeuralNetwork.ActivationFunctions; | ||
|
||
function Step | ||
extends ActivationFunction; | ||
algorithm | ||
y := if u < 0 then 0 else 1; | ||
end Step; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
within NeuralNetwork.ActivationFunctions; | ||
|
||
function Tanh | ||
extends ActivationFunction; | ||
algorithm | ||
y := tanh(u); | ||
end Tanh; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
within NeuralNetwork; | ||
|
||
package ActivationFunctions | ||
extends Modelica.Icons.FunctionsPackage; | ||
extends Modelica.Icons.Package; | ||
annotation( | ||
Icon(graphics = {Line(points = {{-80, -80}, {-47.8, -78.7}, {-35.8, -75.7}, {-27.7, -70.6}, {-22.1, -64.2}, {-17.3, -55.9}, {-12.5, -44.3}, {-7.64, -29.2}, {-1.21, -4.82}, {6.83, 26.3}, {11.7, 42}, {16.5, 54.2}, {21.3, 63.1}, {26.9, 69.9}, {34.2, 75}, {45.4, 78.4}, {72, 79.9}, {80, 80}}, thickness = 1, smooth = Smooth.Bezier)})); | ||
end ActivationFunctions; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,7 @@ | ||
ReLu | ||
ActivationFunction | ||
Id | ||
Step | ||
Sigmoid | ||
activationFunction | ||
Tanh | ||
ReLu | ||
Softplus |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
Layer | ||
ActivationFunctions | ||
Types | ||
Networks | ||
Examples |