LWNEURALNET

NAME
SYNOPSIS
DESCRIPTION
AUTHOR

NAME

net_add_neurons, net_allocate, net_allocate_l, net_begin_batch, net_bload, net_bsave, net_compute, net_compute_output_error, net_copy, net_end_batch, net_fbprint, net_fbscan, net_fprint, net_free, net_fscan, net_get_learning_rate, net_get_momentum, net_get_no_of_inputs, net_get_no_of_layers, net_get_no_of_outputs, net_get_output_error, net_get_weight, net_jolt, net_load, net_overwrite, net_print, net_randomize, net_remove_neurons, net_reset_deltas, net_save, net_set_momentum, net_set_learning_rate, net_train, net_train_batch − lightweight backpropagation neural network

SYNOPSIS

#include <lwneuralnet.h>

void net_add_neurons (network_t *net, int layer, int neuron, int number, float range);

network_t *net_allocate (int n, int i0, int i1 , ..., int i(n-1));

network_t *net_allocate_l (int n, int *list);

void net_begin_batch (network_t *net);

network_t *net_bload (char *filename);

int net_bsave (const char *filename, const network_t *net);

void net_compute (network_t *net, const float *input, float *output);

float net_compute_output_error(network_t *net, const float *target);

network_t *net_copy (const network_t *net);

void net_end_batch (network_t *net);

int net_fbprint (FILE *file, const network_t *net);

network_t *net_fbscan (FILE *file);

int net_fprint (FILE *file, const network_t *net);

void net_free (network_t *net);

network_t *net_fscan (FILE *file);

float net_get_momentum (const network_t *net);

int net_get_no_of_inputs (const network_t *net);

int net_get_no_of_layers (const network_t *net);

int net_get_no_of_outputs (const network_t *net);

float net_get_output_error(network_t *net);

float net_get_weight (const network_t *net, int to_layer, int from_neuron, int to_neuron);

void net_jolt (network_t *net, float factor, float range);

float net_get_learning_rate (const network_t *net);

network_t *net_load (char *filename);

void net_overwrite (network_t *dest, const network_t *src);

void net_randomize (network_t *net, float range);

void net_remove_neurons (network_t *net, int layer, int neuron, int number);

void net_reset_deltas (network_t *net);

int net_print (FILE *file, const network_t *net);

int net_save (const char *filename, const network_t *net);

void net_set_learning_rate (network_t *net, float rate);

void net_set_momentum (network_t *net, float momentum);

void net_set_weight (network_t *net, int to_layer, int from_neuron, int to_neuron , float weight);

void net_train (network_t *net);

void net_train_batch (network_t *net);

DESCRIPTION

net_add_neurons

Add neurons to layer layer of the neural network. The input layer has number 0 and the output layer has number net_no_of_layers(net) - 1. The new neurons get inserted before the neuronth neuron of this layer, where the neurons are numbered staring from 0. As a special case, -1 can be specified to add the neurons after the last neuron of this layer. The new neurons will be connected to the other neurons with random weights from the interval [-range, range].

net_allocate

Allocate resources for a neural network. The number of layers is n, including the input and output layer, i0 is the number of neurons in the input layer, i(n-1) is the number of neurons in the output layer and i2, ...,i(n-2) are the number of neurons in the hidden layers. Return value is a pointer to the newly allocated neural network.

net_allocate_l

Allocate resources for a neural network. In contrast to net_allocate, this routine takes a pointer to an array containing the number of neurons in each layer. Return value is a pointer to the newly allocated neural network.

net_begin_batch

Start a new batch for batch training.

net_bload

Read a binary representation of a neural network from a file. The file is specified by filename. This route will open the file before reading from it and will close it after reading from it. Resources for this network are allocated as with net_allocate and it is the caller’s responsibility to free these resources with net_free when the network is no longer needed. Return value is a pointer to the newly allocated and read neural network on success and NULL on failure.

net_bsave

Write a binary representation of the neural network to a file. The file is specified by filename. This routine will open the file before writing to it and will close it after writing to it. Return value is 0 on success and a negative value on failure. Note that this is not necessarily portable across platforms.

net_compute

Compute the outputs of the neural network for the given inputs. The outputs of the network will be copied to output, unless output is NULL.

net_compute_output_error

Compute the output error of the neural network. This routine should be called after a call to net_compute. Return value is the global output error.

net_copy

Copy a neural network. Resources for the copy are allocated as with net_allocate and it is the caller’s responsibility to free these resources with net_free when the copy is no longer needed. Return value is a pointer to the copy.

net_end_batch

End a batch for batch training. This will update the weights of the neural network.

net_fbprint

Write a binary representation of the neural network to a file. Return value is 0 on success and a negative number on failure. Note that this is not necessarily portable across platforms.

net_fbscan

Read a binary representation of a neural network from a file. Resources for this network are allocated as with allocate_network and it is the caller’s responsibility to free these resources with net_free when the network is no longer needed. Return value is a pointer to the newly allocated and read neural network on success and NULL on failure.

net_fprint

Write a representation of the neural network to a file. Return value is 0 on success and a negative number on failure.

net_free

Free the resources allocated for the neural network.

net_fscan

Read a representation of a neural network from a file. Resources for this network are allocated as with allocate_network and it is the caller’s responsibility to free these resources with net_free when the network is no longer needed. Return value is a pointer to the newly allocated and read neural network on success and NULL on failure.

net_get_learning_rate

Get the learning rate of the neural network.

net_get_momentum

Get the momentum of the neural network.

net_get_no_of_inputs

Get the number of inputs of the neural network.

net_get_no_of_layers

Get the number of layers, including the input and output layer, of the neural network.

net_get_no_of_outputs

Get the number of outputs of the neural network.

net_get_no_of_weights

Get the total number of weights of the neural network.

net_get_output_error

Get the output error of the neural network. The routine should be called after a call to net_compute_output_error.

net_get_weight

Get the weight from neuron from_neuron in layer to_layer-1 to neuron to_neuron in layer layer. Note that the layers and neurons are numbered starting from 0.

net_jolt

Make small changes to the weight in the neural network. All weights that are in absolute value smaller than range become a random weight from the interval [-range, range]. All other weights get multiplied by a random factor from the interval [1-factor, 1+factor].

net_load

Read a representation of a neural network from a file. The file is specified by filename. This route will open the file before reading from it and will close it after reading from it. Resources for the network are allocated as with net_allocate and it is the caller’s responsibility to free these resources with net_free when the network is no longer needed. Return value is a pointer to the newly allocated and read neural network on success and NULL on failure.

net_randomize

Assign random weights to the nodes in the neural network. The weights are chosen from a uniform distribution over the interval [-range, range].

net_reset_deltas

Change all the deltas in the neural network to 0.

net_set_learning_rate

Set the learning rate of the neural network.

net_set_momentum

Set the momentum of the neural network.

net_set_weight

Set the weight from neuron from_neuron in layer to_layer-1 to neuron to_neuron in layer layerto the valueweight. Note that the layers and neurons are numbered starting from 0.

net_print

Write a representation of the neural network to stdout. Return value is 0 on success and a negative value on failure.

net_remove_neurons

Remove the neuronth to (neuron+number-1)th neurons from layer layer of the neural network.

net_save

Write a representation of the neural network to a file. The file is specified by filename. This routine will open the file before writing to it and will close it after writing to it. Return value is 0 on success and a negative value on failure.

net_overwrite

Overwrite one neural network with another neural network.

net_train

Train the neural network towards the target. This routine should be called after calls to net_compute and net_compute_output_error. Note that the target to which to train the network is set in the call to net_compute_output_error.

net_train_batch

Compute the changes needed to train the network towards the target. This routine should be called after a call to net_begin_batch and after calls to net_compute and net_compute_output_error. Note that the target to which to train the network is set in the call to net_compute_output_error. The weights of the network will be updated when net_end_batch is called.

AUTHOR

Peter van Rossum <petervr@debian.org>.

Copyright © 2003-2005
Peter van Rossum
SourceForge WebCounter since 29 September 2003
WebCounter
Updated
26 October 2003