FANN Creation/ Execution |
FANN Creation/ ExecutionThe 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 powerfull and effective. If you have more knowledge about ANNs, and desire more control, almost every part of the ANNs can be parametized to create specialized and highly optimal ANNs. Summary
fann_create_standard
Creates a standard fully connected backpropagation neural network. There will be a bias neuron in each layer (except the output layer), and this bias neuron will be connected to all neurons in the next layer. When running the network, the bias nodes always emits 1. To destroy a struct fann use the fann_destroy function. Parameters
ReturnsA pointer to the newly created struct fann. Example// Creating an ANN with 2 input neurons, 1 output neuron, See alsofann_create_standard_array, fann_create_sparse, fann_create_shortcut This function appears in FANN >= 2.0.0. fann_create_standard_array
Just like fann_create_standard, but with an array of layer sizes instead of individual parameters. Example// Creating an ANN with 2 input neurons, 1 output neuron, See alsofann_create_standard, fann_create_sparse, fann_create_shortcut This function appears in FANN >= 2.0.0. fann_create_sparse
Creates a standard backpropagation neural network, which is not fully connected. Parameters
ReturnsA pointer to the newly created struct fann. See alsofann_create_sparse_array, fann_create_standard, fann_create_shortcut This function appears in FANN >= 2.0.0. fann_create_sparse_array
Just like fann_create_sparse, but with an array of layer sizes instead of individual parameters. See fann_create_standard_array for a description of the parameters. See alsofann_create_sparse, fann_create_standard, fann_create_shortcut This function appears in FANN >= 2.0.0. fann_create_shortcut
Creates a standard backpropagation neural network, which is not fully connected and which also has shortcut connections. Shortcut connections are connections that skip layers. A fully connected network with shortcut connections, is a network where all neurons are connected to all neurons in later layers. Including direct connections from the input layer to the output layer. See fann_create_standard for a description of the parameters. See alsofann_create_shortcut_array, fann_create_standard, fann_create_sparse, This function appears in FANN >= 2.0.0. fann_create_shortcut_array
Just like fann_create_shortcut, but with an array of layer sizes instead of individual parameters. See fann_create_standard_array for a description of the parameters. See alsofann_create_shortcut, fann_create_standard, fann_create_sparse This function appears in FANN >= 2.0.0. fann_randomize_weights
Give each connection a random weight between min_weight and max_weight From the beginning the weights are random between -0.1 and 0.1. See alsoThis function appears in FANN >= 1.0.0. fann_init_weights
Initialize the weights using Widrow + Nguyen’s algorithm. This function behaves similarly to fann_randomize_weights. It will use the algorithm developed by Derrick Nguyen and Bernard Widrow to set the weights in such a way as to speed up training. This technique is not always successful, and in some cases can be less efficient than a purely random initialization. The algorithm requires access to the range of the input data (ie, largest and smallest input), and therefore accepts a second argument, data, which is the training data that will be used to train the network. See alsofann_randomize_weights, fann_read_train_from_file This function appears in FANN >= 1.1.0. fann_print_connections
Will print the connections of the ann in a compact matrix, for easy viewing of the internals of the ann. The output from fann_print_connections on a small (2 2 1) network trained on the xor problem Layer / Neuron 012345 This network have five real neurons and two bias neurons. This gives a total of seven neurons named from 0 to 6. The connections between these neurons can be seen in the matrix. “.” is a place where there is no connection, while a character tells how strong the connection is on a scale from a-z. The two real neurons in the hidden layer (neuron 3 and 4 in layer 1) has connection from the three neurons in the previous layer as is visible in the first two lines. The output neuron (6) has connections form the three neurons in the hidden layer 3 - 5 as is visible in the fourth line. To simplify the matrix output neurons is not visible as neurons that connections can come from, and input and bias neurons are not visible as neurons that connections can go to. This function appears in FANN >= 1.2.0. fann_get_network_type
Get the type of neural network it was created as. Parameters
ReturnsThe neural network type from enum fann_network_type_enum See AlsoThis function appears in FANN >= 2.1.0 fann_get_connection_rate
Get the connection rate used when the network was created Parameters
ReturnsThe connection rate This function appears in FANN >= 2.1.0 fann_get_num_layers
Get the number of layers in the network Parameters
ReturnsThe number of layers in the neural network Example// Obtain the number of layers in a neural network This function appears in FANN >= 2.1.0 fann_get_layer_array
Get the number of neurons in each layer in the network. Bias is not included so the layers match the fann_create functions. Parameters
The layers array must be preallocated to at least sizeof(unsigned int) * fann_num_layers() long. This function appears in FANN >= 2.1.0 fann_get_bias_array
Get the number of bias in each layer in the network. Parameters
The bias array must be preallocated to at least sizeof(unsigned int) * fann_num_layers() long. This function appears in FANN >= 2.1.0 fann_get_connection_array
Get the connections in the network. Parameters
The connections array must be preallocated to at least sizeof(struct fann_connection) * fann_get_total_connections() long. This function appears in FANN >= 2.1.0 fann_set_weight_array
Set connections in the network. Parameters
Only the weights can be changed, connections and weights are ignored if they do not already exist in the network. The array must have sizeof(struct fann_connection) * num_connections size. This function appears in FANN >= 2.1.0 fann_set_weight
Set a connection in the network. Parameters
Only the weights can be changed. The connection/weight is ignored if it does not already exist in the network. This function appears in FANN >= 2.1.0 fann_set_user_data
Store a pointer to user defined data. The pointer can be retrieved with fann_get_user_data for example in a callback. It is the user’s responsibility to allocate and deallocate any data that the pointer might point to. Parameters
This function appears in FANN >= 2.1.0 fann_get_user_data
Get a pointer to user defined data that was previously set with fann_set_user_data. It is the user’s responsibility to allocate and deallocate any data that the pointer might point to. Parameters
ReturnsA void pointer to user defined data. This function appears in FANN >= 2.1.0 fann_get_decimal_point
Returns the position of the decimal point in the ann. This function is only available when the ANN is in fixed point mode. The decimal point is described in greater detail in the tutorial <Fixed Point Usage>. See also<Fixed Point Usage>, fann_get_multiplier, fann_save_to_fixed, fann_save_train_to_fixed This function appears in FANN >= 1.0.0. fann_get_multiplier
returns the multiplier that fix point data is multiplied with. This function is only available when the ANN is in fixed point mode. The multiplier is the used to convert between floating point and fixed point notation. A floating point number is multiplied with the multiplier in order to get the fixed point number and visa versa. The multiplier is described in greater detail in the tutorial <Fixed Point Usage>. See also<Fixed Point Usage>, fann_get_decimal_point, fann_save_to_fixed, fann_save_train_to_fixed This function appears in FANN >= 1.0.0. |
Creates a standard fully connected backpropagation neural network.
FANN_EXTERNAL struct fann *FANN_API fann_create_standard( unsigned int num_layers, ... )
Just like fann_create_standard, but with an array of layer sizes instead of individual parameters.
FANN_EXTERNAL struct fann *FANN_API fann_create_standard_array( unsigned int num_layers, const unsigned int * layers )
Creates a standard backpropagation neural network, which is not fully connected.
FANN_EXTERNAL struct fann *FANN_API fann_create_sparse( float connection_rate, unsigned int num_layers, ... )
Just like fann_create_sparse, but with an array of layer sizes instead of individual parameters.
FANN_EXTERNAL struct fann *FANN_API fann_create_sparse_array( float connection_rate, unsigned int num_layers, const unsigned int * layers )
Creates a standard backpropagation neural network, which is not fully connected and which also has shortcut connections.
FANN_EXTERNAL struct fann *FANN_API fann_create_shortcut( unsigned int num_layers, ... )
Just like fann_create_shortcut, but with an array of layer sizes instead of individual parameters.
FANN_EXTERNAL struct fann *FANN_API fann_create_shortcut_array( unsigned int num_layers, const unsigned int * layers )
Destroys the entire network and properly freeing all the associated memmory.
FANN_EXTERNAL void FANN_API fann_destroy( struct fann * ann )
Will run input through the neural network, returning an array of outputs, the number of which being equal to the number of neurons in the output layer.
FANN_EXTERNAL fann_type * FANN_API fann_run( struct fann * ann, fann_type * input )
Give each connection a random weight between min_weight and max_weight
FANN_EXTERNAL void FANN_API fann_randomize_weights( struct fann * ann, fann_type min_weight, fann_type max_weight )
Initialize the weights using Widrow + Nguyen’s algorithm.
FANN_EXTERNAL void FANN_API fann_init_weights( struct fann * ann, struct fann_train_data * train_data )
Will print the connections of the ann in a compact matrix, for easy viewing of the internals of the ann.
FANN_EXTERNAL void FANN_API fann_print_connections( struct fann * ann )
Prints all of the parameters and options of the ANN
FANN_EXTERNAL void FANN_API fann_print_parameters( struct fann * ann )
Get the number of input neurons.
FANN_EXTERNAL unsigned int FANN_API fann_get_num_input( struct fann * ann )
Get the number of output neurons.
FANN_EXTERNAL unsigned int FANN_API fann_get_num_output( struct fann * ann )
Get the total number of neurons in the entire network.
FANN_EXTERNAL unsigned int FANN_API fann_get_total_neurons( struct fann * ann )
Get the total number of connections in the entire network.
FANN_EXTERNAL unsigned int FANN_API fann_get_total_connections( struct fann * ann )
Get the type of neural network it was created as.
FANN_EXTERNAL enum fann_nettype_enum FANN_API fann_get_network_type( struct fann * ann )
Get the connection rate used when the network was created
FANN_EXTERNAL float FANN_API fann_get_connection_rate( struct fann * ann )
Get the number of layers in the network
FANN_EXTERNAL unsigned int FANN_API fann_get_num_layers( struct fann * ann )
Get the number of neurons in each layer in the network.
FANN_EXTERNAL void FANN_API fann_get_layer_array( struct fann * ann, unsigned int * layers )
Get the number of bias in each layer in the network.
FANN_EXTERNAL void FANN_API fann_get_bias_array( struct fann * ann, unsigned int * bias )
Get the connections in the network.
FANN_EXTERNAL void FANN_API fann_get_connection_array( struct fann * ann, struct fann_connection * connections )
Set connections in the network.
FANN_EXTERNAL void FANN_API fann_set_weight_array( struct fann * ann, struct fann_connection * connections, unsigned int num_connections )
Set a connection in the network.
FANN_EXTERNAL void FANN_API fann_set_weight( struct fann * ann, unsigned int from_neuron, unsigned int to_neuron, fann_type weight )
Store a pointer to user defined data.
FANN_EXTERNAL void FANN_API fann_set_user_data( struct fann * ann, void * user_data )
Get a pointer to user defined data that was previously set with fann_set_user_data.
FANN_EXTERNAL void * FANN_API fann_get_user_data( struct fann * ann )
Returns the position of the decimal point in the ann.
FANN_EXTERNAL unsigned int FANN_API fann_get_decimal_point( struct fann * ann )
returns the multiplier that fix point data is multiplied with.
FANN_EXTERNAL unsigned int FANN_API fann_get_multiplier( struct fann * ann )
Does the same as fann_train_on_data, but reads the training data directly from a file.
FANN_EXTERNAL void FANN_API fann_train_on_file( struct fann * ann, const char * filename, unsigned int max_epochs, unsigned int epochs_between_reports, float desired_error )
Test with a set of inputs, and a set of desired outputs.
FANN_EXTERNAL fann_type * FANN_API fann_test( struct fann * ann, fann_type * input, fann_type * desired_output )
Reads a file that stores training data.
FANN_EXTERNAL struct fann_train_data *FANN_API fann_read_train_from_file( const char * filename )
Saves the entire network to a configuration file.
FANN_EXTERNAL int FANN_API fann_save_to_fixed( struct fann * ann, const char * configuration_file )
Saves the training structure to a fixed point data file.
FANN_EXTERNAL int FANN_API fann_save_train_to_fixed( struct fann_train_data * data, const char * filename, unsigned int decimal_point )