Crate fann_sys

source ·
Expand description

Raw bindings to C functions of the Fast Artificial Neural Network library

§Creation/Execution

The FANN library is designed to be very easy to use. A feedforward ANN can be created by a simple fann_create_standard function, while other ANNs can be created just as easily. The ANNs can be trained by fann_train_on_file and executed by fann_run.

All of this can be done without much knowledge of the internals of ANNs, although the ANNs created will still be powerful and effective. If you have more knowledge about ANNs, and desire more control, almost every part of the ANNs can be parametrized to create specialized and highly optimal ANNs.

§Training

There are many different ways of training neural networks and the FANN library supports a number of different approaches.

Two fundementally different approaches are the most commonly used:

  • Fixed topology training - The size and topology of the ANN is determined in advance and the training alters the weights in order to minimize the difference between the desired output values and the actual output values. This kind of training is supported by fann_train_on_data.

  • Evolving topology training - The training start out with an empty ANN, only consisting of input and output neurons. Hidden neurons and connections are added during training, in order to achieve the same goal as for fixed topology training. This kind of training is supported by FANN Cascade Training.

§Cascade Training

Cascade training differs from ordinary training in the sense that it starts with an empty neural network and then adds neurons one by one, while it trains the neural network. The main benefit of this approach is that you do not have to guess the number of hidden layers and neurons prior to training, but cascade training has also proved better at solving some problems.

The basic idea of cascade training is that a number of candidate neurons are trained separate from the real network, then the most promising of these candidate neurons is inserted into the neural network. Then the output connections are trained and new candidate neurons are prepared. The candidate neurons are created as shortcut connected neurons in a new hidden layer, which means that the final neural network will consist of a number of hidden layers with one shortcut connected neuron in each.

§File Input/Output

It is possible to save an entire ann to a file with fann_save for future loading with fann_create_from_file.

§Error Handling

Errors from the FANN library are usually reported on stderr. It is however possible to redirect these error messages to a file, or completely ignore them with the fann_set_error_log function.

It is also possible to inspect the last error message by using the fann_get_errno and fann_get_errstr functions.

§Datatypes

The two main datatypes used in the FANN library are fann, which represents an artificial neural network, and fann_train_data, which represents training data.

Re-exports§

Structs§

  • The fast artificial neural network (fann) structure.
  • Describes a connection between two neurons and its weight.
  • Structure used to store error-related information, both fann and fann_train_data can be cast to this type.
  • Structure used to store data, for use with training.

Enums§

  • The activation functions used for the neurons during training. The activation functions can either be defined for a group of neurons by fann_set_activation_function_hidden and fann_set_activation_function_output, or it can be defined for a single neuron by fann_set_activation_function.
  • Error events on fann and fann_train_data.
  • Error function used during training.
  • Definition of network types used by fann_get_network_type.
  • Stop criteria used during training.
  • The Training algorithms used when training on fann_train_data with functions like fann_train_on_data or fann_train_on_file. The incremental training alters the weights after each time it is presented an input pattern, while batch only alters the weights once after it has been presented to all the patterns.

Statics§

Functions§

Type Aliases§

  • This callback function can be called during training when using fann_train_on_data, fann_train_on_file or fann_cascadetrain_on_data.
  • The type of weights, inputs and outputs in a neural network. In the Rust bindings, it is defined as c_float by default, and as c_double, if the double feature is configured.