Basic module for creating and using Artificial Neural Networks (ANNs).
Representing an Artificial Neural Network
Network.create [(1, 0.5), (2, -0.1)] [(1, 2, -0.5)]
create : List ( Basics.Int, Basics.Float ) -> List ( Basics.Int, Basics.Int, Basics.Float ) -> Network
create function
Network.create [(1, 0.5), (2, -0.1)] [(1, 2, -0.5)]
setValues : List ( Basics.Int, Basics.Float ) -> Network -> Network
setValues is used to set values of input nodes
someNetwork |> Network.setValues [(0, 1), (1, -0.5)]
activate : Network -> Network
activate updates the network node values using the Step function
someNetwork |> Network.activate
toString : Network -> String
convert Network to String representation
someNetwork |> Network.toString
toDot : Network -> String
toDot create graph description see https://en.wikipedia.org/wiki/DOT_(graph_description_language) can be vizualised with https://rise4fun.com/agl or https://dreampuf.github.io/GraphvizOnline/ or using ports with https://github.com/mdaines/viz.js/
Network.create [(0, 1), (1, 0)] [(0, 1, -0.5)]
|> Network.toDot
-- ==
digraph {
0 [label="0=1"]
1 [label="1=0"]
0 -- 1 [label="-0.5"]
}
fitness : List ( List ( Basics.Int, Basics.Float ), List ( Basics.Int, Basics.Float ) ) -> Network -> Basics.Float
fitness function defined as 1 - RMSE = 1 - Root of Mean Squared Error, this calcuation is done per sample and then summed for all samples, which should mean the result gives how many correct answer the network gave (kind of). see https://www.researchgate.net/figure/The-root-mean-squared-error-RMSE-when-the-genetic-algorithm-is-implemented-with-fitness_fig1_319382166
Network.create [(1, 0), (2, 0)] [(1, 2, 1.0)]
|> Network.fitness
[ ([(1, 0)], [(2, 0)])
, ([(1, 1)], [(2, 1)])
]
-- == 2.0 (Meaning both samples correctly answered)
get : List Basics.Int -> Network -> List ( Basics.Int, Basics.Float )
get specific nodes with their current values