Neural library

Index:

Functions:

nn-calculate

nn-calculate

Synopsis
Calculates the output of a neural network for an input.
Usage
(nn-calculate net_id input)
Returns
output
Where
  • net_id is string: the identifier of the neural network that is going to be calculated.
  • input is list: the input vector that contains as many numbers as input neurons has the network.
  • output is list: the output vector that contains as many numbers as output neurons has the network.
Description
Calculates the output vector that produces the neural network identified by net_id for the given input vector.
Examples
(nn-calculate net (0 0 1))
(-0.0482173242 -0.98624499854)
Related functions
nn-create

nn-create

Synopsis
Creates a neural network.
Usage
(nn-create "type" => type "neurons" => neurons)
Returns
net_id
Where
  • type is string[0..1]: the type of the network. It can be "MultiLayerPerceptron", "Kohonen", "Hopfield", "Instar" or "Perceptron". When not specified, it is assumed that type is "MultiLayerPerceptron".
  • neurons is list[0..1]: a list that contains the number of neurons of each layer of the network.
  • net_id is string: a unique identifier of the neural network.
Description
Creates a neural network of the given type with the number of neurons specified in the neurons argument.
Examples
(nn-create "neurons" => (3 4 1))
"dbe6f37e369b4bdab1871f0aa7fef96c"
(nn-create
  "type" => "Perceptron"
  "neurons" => (3 3)
)
"e8e3ddf8efb44d5a824d00142624bdb1"
Related functions
nn-destroy

nn-destroy

Synopsis
Destroys a neural network.
Usage
(nn-destroy net_id)
Returns
destroyed
Where
  • net_id is string: the identifier of the neural network to destroy.
  • destroyed is boolean: true if the network was found, false otherwise.
Description
Destroys the neural network identified by net_id.
Examples
(nn-destroy net)
true
Related functions
nn-learn

nn-learn

Synopsis
Trains a neural network.
Usage
(nn-learn
  net_id
  dataset
  "max-error" => max_error
  "max-iterations" => max_iterations
)
Returns
num_iterations
Where
  • net_id is string: the identifier of the neural network that is going to be trained.
  • dataset is list: a list that contains the samples to be learn by the network. Each sample is a list of 2 elements: an input vector and its corresponding output vector. The input vector is a list with as many numbers as input neurons has the network and the output vector is another list with as many numbers as output neurons has the network.
  • max_error is number[0..1]: the maximum error of the learning process when the neural network has a supervised learning method. By default, max_error is 0.01.
  • max_iterations is number[0..1]: the maximum number of iterations of the learning process when the neural network has an iterative learning method.
  • num_iterations is number: the number of iterations the learning process took.
Description
Trains the network identified by net_id to learn the given dataset. Since the learning process may take a long time, a stop condition can be set with the max_error or max_iterations parameters.
In all cases, the learning process can be interrupted by calling the kill function.
Examples
(nn-learn
  net
  (
    ((0 0) (0 1))
    ((0 1) (1 0))
    ((1 0) (1 0))
    ((1 1) (0 1))
  )
  "max-iterations" => 1000
)
524
Related functions
nn-weights

nn-weights

Synopsis
Gets or sets the weights of a neural network.
Usage
(nn-weights net_id new_weights)
Returns
weights
Where
  • net_id is string: the identifier of the neural network whose weights are going to be get or set.
  • new_weights is list[0..1]: a list that contains the new weights of the network connections or null to assign random weights.
  • weights is list: a list that contains the current weights of the network connections.
Description
When new_weights is specified this function replaces the current weights of the neuron connections by the values of new_weights. If new_weights is null, connections are initialized with random weights. When new_weights is not specified, this function returns the current weights of the neuron connections.
This function is used to save and restore the state of a neural network after it has been trained.
Examples
(nn-weights net)
(-0.04821725955574818 -0.01302105397189146)
(nn-weights net (-0.0463 -0.014))
(-0.0463 -0.014)
Related functions
Top