1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
mind
====
This module is used to create arbitrary stateful neural networks.
The only export is the following function:
```
network(input_count, internal_count, output_count, weight_max = 4 : number)
```
This function returns an object that represents a neural network with `input_count` input neurons,
`internal_count` internal (and stateful) neurons, and `output_count` output neurons. `max_weight` determines
the maximum absolute value allowed for connection weights.
A network object has two methods:
```
connect(source, sink, weight : number)
```
This method returns a new network object that is an exact copy of the original, except with a new
connection between the neuron indexed by `source` and `sink`, with weight `weight`. Neuron indices
are zero-indexed, and span all neurons, first the inputs, then the internal neurons, and finally the outputs.
An error will be thrown if `source` is in the range of output neurons or if `sink` is in the range of input
neurons.
```
compute(inputs, state : array[number])
```
This method returns a tuple `[output, newState]`, where `output` is an array of `output_count` values
corresponding to the output neuron's computed values, and `newState` is the new state of the internal neurons.
`input` must be an array of numbers with length equal to `input_count`, and `state` must be an array of numbers
with length equal to `internal_count` or an error will be raised.
|