|Portability||non-portable (requires STM)|
The network of nodes which is build by GSOM consists if nodes of type
and this module contains the definition if this type along with
most of the functions altering or working on them.
- type Neighbours = [TVar Node]
- type Neighbourhood = [(Int, Node)]
- data Node
- type Nodes = [Node]
- isLeaf :: Node -> Bool
- isNode :: Node -> Bool
- neighbourhood :: Node -> Int -> STM Neighbourhood
- newWeight :: Node -> Int -> STM ()
- node :: Coordinates -> Input -> Neighbours -> STM Node
- propagate :: Node -> Nodes -> STM ()
- putNode :: Node -> IO [String]
- unwrappedNeighbours :: Node -> STM Nodes
- update :: Input -> Double -> (Int -> Double) -> (Int, Node) -> STM ()
- updateError :: Node -> Input -> STM ()
The type of neighbourhoods. Wherever a neighbourhood of a node
is neede, this type should be used.
Neighbourhood consits of a list of pairs of nodes and their
discrete grid distance from the source of the neighbourhood.
The source node is the only one with distance
0 while immediate
neighbours get distance one and so on.
The type of nodes of a gsom.
They're either Leafs, signalling neighbours of boundary nodes
or they are actual nodes with a few associated values and a list of neighbouring nodes.
Calculates the neighbourhood of the given size of the given node.
A neighbourhood size of
0 means that only the given node will be
an element of the returned set while a size of one will return the
given node and it's immediate neighbours and so on.
It's not very efficient so you shouldn't try big neihbourhood sizes.
The returned neighbourhood always includes
When a new node is spawned we need to calculate it's new weight vector. If the new node is spawned from parent p in direction d and p has a neighbour n in the direction d' opposite to d then the new weight vector nw is calculated according to the formula:
In all other cases there exists exactly one neighbour of the new node. Let this neighbour be called n and let d' be the direction in which we have to go to reach this neighbour from the new node. Let s then be the child of the new node's parent p in direction d'. The new weights are then calculated according to the formula:
nw = p + n - s.
creates a node with the specified
parameters and initial quantization error of
node id weights neighbours
propagates the accumulated error of the given
to it's neighbours.
the weights of the
update input learning_rate kernel neighbour
neighbour according to the formula:
weight -> weight + learning_rate * (kernel d) (input - weight)