FANN C++ Wrapper

Overview

The Fann Wrapper for C++ provides two classes: neural_net and training_data.  To use the wrapper include doublefann.h, floatfann.h or fixedfann.h before the fann_cpp.h header file.

To get started see xor_sample.cpp in the examples directory.  The license is LGPL.  Copyright © 2004-2006 created by freeg.nosp@m.oldbar@yaho.nosp@m.o.com.

Note: Notes and differences from C API

  • The Fann Wrapper for C++ is a minimal wrapper without use of templates or exception handling for efficient use in any environment.  Benefits include stricter type checking, simpler memory management and possibly code completion in program editor.
  • Method names are the same as the function names in the C API except the fann_ prefix has been removed.  Enums in the namespace are similarly defined without the FANN_ prefix.
  • The arguments to the methods are the same as the C API except that the struct fann *ann/struct fann_train_data *data arguments are encapsulated so they are not present in the method signatures or are translated into class references.
  • C++ style constructors have been implemented to make network creation easier
  • The neural network and training data is automatically cleaned up in the destructors
  • To make the destructors virtual define USE_VIRTUAL_DESTRUCTOR before including the header file.
  • Additional methods are available on the training_data class to give access to the underlying training data.  They are get_input, get_output and set_train_data.  Finally fann_duplicate_train_data has been replaced by a copy constructor.
Summary
FANN C++ WrapperThe Fann Wrapper for C++ provides two classes: neural_net and training_data.
FANNThe FANN namespace groups the C++ wrapper definitions
neural_netneural_net is the main neural network class used for both training and execution
Functions
neural_net(network_type_enum net_type, unsigned int num_layers, const unsigned int *layers)Creates a neural network of the desired network_type_enum net_type, based on array of layers.
neural_net(network_type_enum net_type, InputIterator layersBeginIterator, InputIterator layersEndIterator)Creates a neural network of the desired network_type_enum net_type, based on iterator to the layers.
neural_net(network_type_enum net_type, unsigned int num_layers, ...)Creates a neural network of the desired network_type_enum net_type.
neural_net(float connection_rate, unsigned int num_layers, ...)Creates a standard backpropagation neural network, which is sparsely connected, this will default the network_type_enum to LAYER
neural_net(float connection_rate, unsigned int num_layers, const unsigned int *layers)Creates a standard backpropagation neural network, which is sparsely connected, this will default the network_type_enum to LAYER
neural_net(const std::string &configuration_file)Constructs a backpropagation neural network from a configuration file, which have been saved by save.
neural_net(struct fann *other)Creates a copy the other neural_net.
neural_net() - DEPRECATEDCreates an empty neural net.
copy_from_struct_fann - DEPRECATEDSet the internal fann struct to a copy of other
~neural_netProvides automatic cleanup of data.
destroyDestructs the entire network.
create_standard - DEPRECATEDCreates a standard fully connected backpropagation neural network.
create_standard_array - DEPRECATEDJust like <create_standard>, but with an array of layer sizes instead of individual parameters.
create_sparse - DEPRECATEDCreates a standard backpropagation neural network, which is not fully connected.
create_sparse_array - DEPRECATEDJust like <create_sparse>, but with an array of layer sizes instead of individual parameters.
create_shortcut - DEPRECATEDCreates a standard backpropagation neural network, which is fully connected and which also has shortcut connections.
create_shortcut_array - DEPRECATEDJust like <create_shortcut>, but with an array of layer sizes instead of individual parameters.
runWill 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.
randomize_weightsGive each connection a random weight between min_weight and max_weight
init_weightsInitialize the weights using Widrow + Nguyen’s algorithm.
print_connectionsWill print the connections of the ann in a compact matrix, for easy viewing of the internals of the ann.
create_from_file - DEPRECATEDConstructs a backpropagation neural network from a configuration file, which have been saved by save.
saveSave the entire network to a configuration file.
save_to_fixedSaves the entire network to a configuration file.
trainTrain one iteration with a set of inputs, and a set of desired outputs.
train_epochTrain one epoch with a set of training data.
train_on_dataTrains on an entire dataset, for a period of time.
train_on_fileDoes the same as train_on_data, but reads the training data directly from a file.
testTest with a set of inputs, and a set of desired outputs.
test_dataTest a set of training data and calculates the MSE for the training data.
get_MSEReads the mean square error from the network.
reset_MSEResets the mean square error from the network.
set_callbackSets the callback function for use during training.
print_parametersPrints all of the parameters and options of the neural network
get_training_algorithmReturn the training algorithm as described by <FANN::training_algorithm_enum>.
set_training_algorithmSet the training algorithm.
get_learning_rateReturn the learning rate.
set_learning_rateSet the learning rate.
get_activation_functionGet the activation function for neuron number neuron in layer number layer, counting the input layer as layer 0.
set_activation_functionSet the activation function for neuron number neuron in layer number layer, counting the input layer as layer 0.
set_activation_function_layerSet the activation function for all the neurons in the layer number layer, counting the input layer as layer 0.
set_activation_function_hiddenSet the activation function for all of the hidden layers.
set_activation_function_outputSet the activation function for the output layer.
get_activation_steepnessGet the activation steepness for neuron number neuron in layer number layer, counting the input layer as layer 0.
set_activation_steepnessSet the activation steepness for neuron number neuron in layer number layer, counting the input layer as layer 0.
set_activation_steepness_layerSet the activation steepness all of the neurons in layer number layer, counting the input layer as layer 0.
set_activation_steepness_hiddenSet the steepness of the activation steepness in all of the hidden layers.
set_activation_steepness_outputSet the steepness of the activation steepness in the output layer.
get_train_error_functionReturns the error function used during training.
set_train_error_functionSet the error function used during training.
get_quickprop_decayThe decay is a small negative valued number which is the factor that the weights should become smaller in each iteration during quickprop training.
set_quickprop_decaySets the quickprop decay factor.
get_quickprop_muThe mu factor is used to increase and decrease the step-size during quickprop training.
set_quickprop_muSets the quickprop mu factor.
get_rprop_increase_factorThe increase factor is a value larger than 1, which is used to increase the step-size during RPROP training.
set_rprop_increase_factorThe increase factor used during RPROP training.
get_rprop_decrease_factorThe decrease factor is a value smaller than 1, which is used to decrease the step-size during RPROP training.
set_rprop_decrease_factorThe decrease factor is a value smaller than 1, which is used to decrease the step-size during RPROP training.
get_rprop_delta_zeroThe initial step-size is a small positive number determining how small the initial step-size may be.
set_rprop_delta_zeroThe initial step-size is a small positive number determining how small the initial step-size may be.
get_rprop_delta_minThe minimum step-size is a small positive number determining how small the minimum step-size may be.
set_rprop_delta_minThe minimum step-size is a small positive number determining how small the minimum step-size may be.
get_rprop_delta_maxThe maximum step-size is a positive number determining how large the maximum step-size may be.
set_rprop_delta_maxThe maximum step-size is a positive number determining how large the maximum step-size may be.
get_sarprop_weight_decay_shiftThe sarprop weight decay shift.
set_sarprop_weight_decay_shiftSet the sarprop weight decay shift.
get_sarprop_step_error_threshold_factorThe sarprop step error threshold factor.
set_sarprop_step_error_threshold_factorSet the sarprop step error threshold factor.
get_sarprop_step_error_shiftThe get sarprop step error shift.
set_sarprop_step_error_shiftSet the sarprop step error shift.
get_sarprop_temperatureThe sarprop weight decay shift.
set_sarprop_temperatureSet the sarprop_temperature.
get_num_inputGet the number of input neurons.
get_num_outputGet the number of output neurons.
get_total_neuronsGet the total number of neurons in the entire network.
get_total_connectionsGet the total number of connections in the entire network.
get_decimal_pointReturns the position of the decimal point in the ann.
get_multiplierReturns the multiplier that fix point data is multiplied with.
get_network_typeGet the type of neural network it was created as.
get_connection_rateGet the connection rate used when the network was created
get_num_layersGet the number of layers in the network
get_layer_arrayGet the number of neurons in each layer in the network.
get_bias_arrayGet the number of bias in each layer in the network.
get_connection_arrayGet the connections in the network.
set_weight_arraySet connections in the network.
set_weightSet a connection in the network.
get_learning_momentumGet the learning momentum.
set_learning_momentumSet the learning momentum.
get_train_stop_functionReturns the the stop function used during training.
set_train_stop_functionSet the stop function used during training.
get_bit_fail_limitReturns the bit fail limit used during training.
set_bit_fail_limitSet the bit fail limit used during training.
get_bit_failThe number of fail bits; means the number of output neurons which differ more than the bit fail limit (see get_bit_fail_limit, set_bit_fail_limit).
cascadetrain_on_dataTrains on an entire dataset, for a period of time using the Cascade2 training algorithm.
cascadetrain_on_fileDoes the same as cascadetrain_on_data, but reads the training data directly from a file.
get_cascade_output_change_fractionThe cascade output change fraction is a number between 0 and 1 determining how large a fraction the get_MSE value should change within get_cascade_output_stagnation_epochs during training of the output connections, in order for the training not to stagnate.
set_cascade_output_change_fractionSets the cascade output change fraction.
get_cascade_output_stagnation_epochsThe number of cascade output stagnation epochs determines the number of epochs training is allowed to continue without changing the MSE by a fraction of get_cascade_output_change_fraction.
set_cascade_output_stagnation_epochsSets the number of cascade output stagnation epochs.
get_cascade_candidate_change_fractionThe cascade candidate change fraction is a number between 0 and 1 determining how large a fraction the get_MSE value should change within get_cascade_candidate_stagnation_epochs during training of the candidate neurons, in order for the training not to stagnate.
set_cascade_candidate_change_fractionSets the cascade candidate change fraction.
get_cascade_candidate_stagnation_epochsThe number of cascade candidate stagnation epochs determines the number of epochs training is allowed to continue without changing the MSE by a fraction of get_cascade_candidate_change_fraction.
set_cascade_candidate_stagnation_epochsSets the number of cascade candidate stagnation epochs.
get_cascade_weight_multiplierThe weight multiplier is a parameter which is used to multiply the weights from the candidate neuron before adding the neuron to the neural network.
set_cascade_weight_multiplierSets the weight multiplier.
get_cascade_candidate_limitThe candidate limit is a limit for how much the candidate neuron may be trained.
set_cascade_candidate_limitSets the candidate limit.
get_cascade_max_out_epochsThe maximum out epochs determines the maximum number of epochs the output connections may be trained after adding a new candidate neuron.
set_cascade_max_out_epochsSets the maximum out epochs.
get_cascade_max_cand_epochsThe maximum candidate epochs determines the maximum number of epochs the input connections to the candidates may be trained before adding a new candidate neuron.
set_cascade_max_cand_epochsSets the max candidate epochs.
get_cascade_num_candidatesThe number of candidates used during training (calculated by multiplying get_cascade_activation_functions_count, get_cascade_activation_steepnesses_count and get_cascade_num_candidate_groups).
get_cascade_activation_functions_countThe number of activation functions in the get_cascade_activation_functions array.
get_cascade_activation_functionsThe cascade activation functions array is an array of the different activation functions used by the candidates.
set_cascade_activation_functionsSets the array of cascade candidate activation functions.
get_cascade_activation_steepnesses_countThe number of activation steepnesses in the get_cascade_activation_functions array.
get_cascade_activation_steepnessesThe cascade activation steepnesses array is an array of the different activation functions used by the candidates.
set_cascade_activation_steepnessesSets the array of cascade candidate activation steepnesses.
get_cascade_num_candidate_groupsThe number of candidate groups is the number of groups of identical candidates which will be used during training.
set_cascade_num_candidate_groupsSets the number of candidate groups.
scale_trainScale input and output data based on previously calculated parameters.
descale_trainDescale input and output data based on previously calculated parameters.
set_input_scaling_paramsCalculate scaling parameters for future use based on training data.
set_output_scaling_paramsCalculate scaling parameters for future use based on training data.
set_scaling_paramsCalculate scaling parameters for future use based on training data.
clear_scaling_paramsClears scaling parameters.
scale_inputScale data in input vector before feed it to ann based on previously calculated parameters.
scale_outputScale data in output vector before feed it to ann based on previously calculated parameters.
descale_inputScale data in input vector after get it from ann based on previously calculated parameters.
descale_outputScale data in output vector after get it from ann based on previously calculated parameters.
set_error_logChange where errors are logged to.
get_errnoReturns the last error number.
reset_errnoResets the last error number.
reset_errstrResets the last error string.
get_errstrReturns the last errstr.
print_errorPrints the last error to stderr.
disable_seed_randDisables the automatic random generator seeding that happens in FANN.
enable_seed_randEnables the automatic random generator seeding that happens in FANN.

FANN

namespace FANN

The FANN namespace groups the C++ wrapper definitions

neural_net

class neural_net

neural_net is the main neural network class used for both training and execution

Encapsulation of a neural network struct fann and associated C API functions.

Summary
Functions
neural_net(network_type_enum net_type, unsigned int num_layers, const unsigned int *layers)Creates a neural network of the desired network_type_enum net_type, based on array of layers.
neural_net(network_type_enum net_type, InputIterator layersBeginIterator, InputIterator layersEndIterator)Creates a neural network of the desired network_type_enum net_type, based on iterator to the layers.
neural_net(network_type_enum net_type, unsigned int num_layers, ...)Creates a neural network of the desired network_type_enum net_type.
neural_net(float connection_rate, unsigned int num_layers, ...)Creates a standard backpropagation neural network, which is sparsely connected, this will default the network_type_enum to LAYER
neural_net(float connection_rate, unsigned int num_layers, const unsigned int *layers)Creates a standard backpropagation neural network, which is sparsely connected, this will default the network_type_enum to LAYER
neural_net(const std::string &configuration_file)Constructs a backpropagation neural network from a configuration file, which have been saved by save.
neural_net(struct fann *other)Creates a copy the other neural_net.
neural_net() - DEPRECATEDCreates an empty neural net.
copy_from_struct_fann - DEPRECATEDSet the internal fann struct to a copy of other
~neural_netProvides automatic cleanup of data.
destroyDestructs the entire network.
create_standard - DEPRECATEDCreates a standard fully connected backpropagation neural network.
create_standard_array - DEPRECATEDJust like <create_standard>, but with an array of layer sizes instead of individual parameters.
create_sparse - DEPRECATEDCreates a standard backpropagation neural network, which is not fully connected.
create_sparse_array - DEPRECATEDJust like <create_sparse>, but with an array of layer sizes instead of individual parameters.
create_shortcut - DEPRECATEDCreates a standard backpropagation neural network, which is fully connected and which also has shortcut connections.
create_shortcut_array - DEPRECATEDJust like <create_shortcut>, but with an array of layer sizes instead of individual parameters.
runWill 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.
randomize_weightsGive each connection a random weight between min_weight and max_weight
init_weightsInitialize the weights using Widrow + Nguyen’s algorithm.
print_connectionsWill print the connections of the ann in a compact matrix, for easy viewing of the internals of the ann.
create_from_file - DEPRECATEDConstructs a backpropagation neural network from a configuration file, which have been saved by save.
saveSave the entire network to a configuration file.
save_to_fixedSaves the entire network to a configuration file.
trainTrain one iteration with a set of inputs, and a set of desired outputs.
train_epochTrain one epoch with a set of training data.
train_on_dataTrains on an entire dataset, for a period of time.
train_on_fileDoes the same as train_on_data, but reads the training data directly from a file.
testTest with a set of inputs, and a set of desired outputs.
test_dataTest a set of training data and calculates the MSE for the training data.
get_MSEReads the mean square error from the network.
reset_MSEResets the mean square error from the network.
set_callbackSets the callback function for use during training.
print_parametersPrints all of the parameters and options of the neural network
get_training_algorithmReturn the training algorithm as described by <FANN::training_algorithm_enum>.
set_training_algorithmSet the training algorithm.
get_learning_rateReturn the learning rate.
set_learning_rateSet the learning rate.
get_activation_functionGet the activation function for neuron number neuron in layer number layer, counting the input layer as layer 0.
set_activation_functionSet the activation function for neuron number neuron in layer number layer, counting the input layer as layer 0.
set_activation_function_layerSet the activation function for all the neurons in the layer number layer, counting the input layer as layer 0.
set_activation_function_hiddenSet the activation function for all of the hidden layers.
set_activation_function_outputSet the activation function for the output layer.
get_activation_steepnessGet the activation steepness for neuron number neuron in layer number layer, counting the input layer as layer 0.
set_activation_steepnessSet the activation steepness for neuron number neuron in layer number layer, counting the input layer as layer 0.
set_activation_steepness_layerSet the activation steepness all of the neurons in layer number layer, counting the input layer as layer 0.
set_activation_steepness_hiddenSet the steepness of the activation steepness in all of the hidden layers.
set_activation_steepness_outputSet the steepness of the activation steepness in the output layer.
get_train_error_functionReturns the error function used during training.
set_train_error_functionSet the error function used during training.
get_quickprop_decayThe decay is a small negative valued number which is the factor that the weights should become smaller in each iteration during quickprop training.
set_quickprop_decaySets the quickprop decay factor.
get_quickprop_muThe mu factor is used to increase and decrease the step-size during quickprop training.
set_quickprop_muSets the quickprop mu factor.
get_rprop_increase_factorThe increase factor is a value larger than 1, which is used to increase the step-size during RPROP training.
set_rprop_increase_factorThe increase factor used during RPROP training.
get_rprop_decrease_factorThe decrease factor is a value smaller than 1, which is used to decrease the step-size during RPROP training.
set_rprop_decrease_factorThe decrease factor is a value smaller than 1, which is used to decrease the step-size during RPROP training.
get_rprop_delta_zeroThe initial step-size is a small positive number determining how small the initial step-size may be.
set_rprop_delta_zeroThe initial step-size is a small positive number determining how small the initial step-size may be.
get_rprop_delta_minThe minimum step-size is a small positive number determining how small the minimum step-size may be.
set_rprop_delta_minThe minimum step-size is a small positive number determining how small the minimum step-size may be.
get_rprop_delta_maxThe maximum step-size is a positive number determining how large the maximum step-size may be.
set_rprop_delta_maxThe maximum step-size is a positive number determining how large the maximum step-size may be.
get_sarprop_weight_decay_shiftThe sarprop weight decay shift.
set_sarprop_weight_decay_shiftSet the sarprop weight decay shift.
get_sarprop_step_error_threshold_factorThe sarprop step error threshold factor.
set_sarprop_step_error_threshold_factorSet the sarprop step error threshold factor.
get_sarprop_step_error_shiftThe get sarprop step error shift.
set_sarprop_step_error_shiftSet the sarprop step error shift.
get_sarprop_temperatureThe sarprop weight decay shift.
set_sarprop_temperatureSet the sarprop_temperature.
get_num_inputGet the number of input neurons.
get_num_outputGet the number of output neurons.
get_total_neuronsGet the total number of neurons in the entire network.
get_total_connectionsGet the total number of connections in the entire network.
get_decimal_pointReturns the position of the decimal point in the ann.
get_multiplierReturns the multiplier that fix point data is multiplied with.
get_network_typeGet the type of neural network it was created as.
get_connection_rateGet the connection rate used when the network was created
get_num_layersGet the number of layers in the network
get_layer_arrayGet the number of neurons in each layer in the network.
get_bias_arrayGet the number of bias in each layer in the network.
get_connection_arrayGet the connections in the network.
set_weight_arraySet connections in the network.
set_weightSet a connection in the network.
get_learning_momentumGet the learning momentum.
set_learning_momentumSet the learning momentum.
get_train_stop_functionReturns the the stop function used during training.
set_train_stop_functionSet the stop function used during training.
get_bit_fail_limitReturns the bit fail limit used during training.
set_bit_fail_limitSet the bit fail limit used during training.
get_bit_failThe number of fail bits; means the number of output neurons which differ more than the bit fail limit (see get_bit_fail_limit, set_bit_fail_limit).
cascadetrain_on_dataTrains on an entire dataset, for a period of time using the Cascade2 training algorithm.
cascadetrain_on_fileDoes the same as cascadetrain_on_data, but reads the training data directly from a file.
get_cascade_output_change_fractionThe cascade output change fraction is a number between 0 and 1 determining how large a fraction the get_MSE value should change within get_cascade_output_stagnation_epochs during training of the output connections, in order for the training not to stagnate.
set_cascade_output_change_fractionSets the cascade output change fraction.
get_cascade_output_stagnation_epochsThe number of cascade output stagnation epochs determines the number of epochs training is allowed to continue without changing the MSE by a fraction of get_cascade_output_change_fraction.
set_cascade_output_stagnation_epochsSets the number of cascade output stagnation epochs.
get_cascade_candidate_change_fractionThe cascade candidate change fraction is a number between 0 and 1 determining how large a fraction the get_MSE value should change within get_cascade_candidate_stagnation_epochs during training of the candidate neurons, in order for the training not to stagnate.
set_cascade_candidate_change_fractionSets the cascade candidate change fraction.
get_cascade_candidate_stagnation_epochsThe number of cascade candidate stagnation epochs determines the number of epochs training is allowed to continue without changing the MSE by a fraction of get_cascade_candidate_change_fraction.
set_cascade_candidate_stagnation_epochsSets the number of cascade candidate stagnation epochs.
get_cascade_weight_multiplierThe weight multiplier is a parameter which is used to multiply the weights from the candidate neuron before adding the neuron to the neural network.
set_cascade_weight_multiplierSets the weight multiplier.
get_cascade_candidate_limitThe candidate limit is a limit for how much the candidate neuron may be trained.
set_cascade_candidate_limitSets the candidate limit.
get_cascade_max_out_epochsThe maximum out epochs determines the maximum number of epochs the output connections may be trained after adding a new candidate neuron.
set_cascade_max_out_epochsSets the maximum out epochs.
get_cascade_max_cand_epochsThe maximum candidate epochs determines the maximum number of epochs the input connections to the candidates may be trained before adding a new candidate neuron.
set_cascade_max_cand_epochsSets the max candidate epochs.
get_cascade_num_candidatesThe number of candidates used during training (calculated by multiplying get_cascade_activation_functions_count, get_cascade_activation_steepnesses_count and get_cascade_num_candidate_groups).
get_cascade_activation_functions_countThe number of activation functions in the get_cascade_activation_functions array.
get_cascade_activation_functionsThe cascade activation functions array is an array of the different activation functions used by the candidates.
set_cascade_activation_functionsSets the array of cascade candidate activation functions.
get_cascade_activation_steepnesses_countThe number of activation steepnesses in the get_cascade_activation_functions array.
get_cascade_activation_steepnessesThe cascade activation steepnesses array is an array of the different activation functions used by the candidates.
set_cascade_activation_steepnessesSets the array of cascade candidate activation steepnesses.
get_cascade_num_candidate_groupsThe number of candidate groups is the number of groups of identical candidates which will be used during training.
set_cascade_num_candidate_groupsSets the number of candidate groups.
scale_trainScale input and output data based on previously calculated parameters.
descale_trainDescale input and output data based on previously calculated parameters.
set_input_scaling_paramsCalculate scaling parameters for future use based on training data.
set_output_scaling_paramsCalculate scaling parameters for future use based on training data.
set_scaling_paramsCalculate scaling parameters for future use based on training data.
clear_scaling_paramsClears scaling parameters.
scale_inputScale data in input vector before feed it to ann based on previously calculated parameters.
scale_outputScale data in output vector before feed it to ann based on previously calculated parameters.
descale_inputScale data in input vector after get it from ann based on previously calculated parameters.
descale_outputScale data in output vector after get it from ann based on previously calculated parameters.
set_error_logChange where errors are logged to.
get_errnoReturns the last error number.
reset_errnoResets the last error number.
reset_errstrResets the last error string.
get_errstrReturns the last errstr.
print_errorPrints the last error to stderr.
disable_seed_randDisables the automatic random generator seeding that happens in FANN.
enable_seed_randEnables the automatic random generator seeding that happens in FANN.

Functions

neural_net(network_type_enum net_type, unsigned int num_layers, const unsigned int *layers)

neural_net(network_type_enum net_type,
unsigned int num_layers,
const unsigned int *layers)

Creates a neural network of the desired network_type_enum net_type, based on array of layers.

Parameters

net_typeThe desired network type of the neural network
num_layersThe total number of layers including the input and the output layer.
layersarray of the layer sizes

NOTE: if layers does not have the same size as num_layers, the result is undefined

Example

FANN::neural_net net(LAYER, 3, (unsigned int[]) {2, 3, 1});

This function appears in FANN >= 2.3.0.

neural_net(network_type_enum net_type, InputIterator layersBeginIterator, InputIterator layersEndIterator)

template <class InputIterator> neural_net(network_type_enum net_type,
InputIterator layersBeginIterator,
InputIterator layersEndIterator)

Creates a neural network of the desired network_type_enum net_type, based on iterator to the layers.

Parameters

net_typeThe desired network type of the neural network
layersBeginIteratorbegin iterator to the collection of unsigned int layers
layersEndIteratorend iterator to the collection of unsigned int layers

Example

vector<unsigned int> layers{2, 3, 4, 5};
neural_net net(LAYER, layers.begin(), layers.end());

This function appears in FANN >= 2.3.0.

neural_net(network_type_enum net_type, unsigned int num_layers, ...)

neural_net(network_type_enum net_type,
unsigned int num_layers,
 ...)

Creates a neural network of the desired network_type_enum net_type.

Parameters

num_layersThe total number of layers including the input and the output layer.
...Integer values determining the number of neurons in each layer starting with the input layer and ending with the output layer.

Example

const unsigned int num_layers = 3;
const unsigned int num_input = 2;
const unsigned int num_hidden = 3;
const unsigned int num_output = 1;

FANN::neural_net net(num_layers, num_input, num_hidden, num_output);

This function appears in FANN >= 2.3.0.

neural_net(float connection_rate, unsigned int num_layers, ...)

neural_net(float connection_rate,
unsigned int num_layers,
 ...)

Creates a standard backpropagation neural network, which is sparsely connected, this will default the network_type_enum to LAYER

Parameters

connection_rateThe connection rate controls how many connections there will be in the network.  If the connection rate is set to 1, the network will be fully connected, but if it is set to 0.5 only half of the connections will be set.  A connection rate of 1 will yield the same result as fann_create_standard
num_layersThe total number of layers including the input and the output layer.
...Integer values determining the number of neurons in each layer starting with the input layer and ending with the output layer.

This function appears in FANN >= 2.3.0.

neural_net(float connection_rate, unsigned int num_layers, const unsigned int *layers)

neural_net(float connection_rate,
unsigned int num_layers,
const unsigned int *layers)

Creates a standard backpropagation neural network, which is sparsely connected, this will default the network_type_enum to LAYER

Parameters

connection_rateThe connection rate controls how many connections there will be in the network.  If the connection rate is set to 1, the network will be fully connected, but if it is set to 0.5 only half of the connections will be set.  A connection rate of 1 will yield the same result as fann_create_standard
num_layersThe total number of layers including the input and the output layer.
layersInteger values determining the number of neurons in each layer starting with the input layer and ending with the output layer.

This function appears in FANN >= 2.3.0.

neural_net(const std::string &configuration_file)

neural_net(const std::string &configuration_file)

Constructs a backpropagation neural network from a configuration file, which have been saved by save.

See also

save, save_to_fixed

This function appears in FANN >= 2.3.0.

neural_net(struct fann *other)

neural_net(struct fann *other)

Creates a copy the other neural_net.

neural_net() - DEPRECATED

neural_net() : ann(NULL)

Creates an empty neural net.  Use one of the create functions to create the neural network.

NOTE: As of version 2.3.0 it recommended to create neural networks using the constructors instead of creating an empty network and setting the internal structure of that.  This method is hence discouraged and will be deprecated later on.

See also

<create_standard>, <create_sparse>, <create_shortcut>, <create_standard_array>, <create_sparse_array>, <create_shortcut_array>

copy_from_struct_fann - DEPRECATED

Set the internal fann struct to a copy of other

NOTE: As of version 2.3.0 it recommended to create neural networks using the constructors instead of creating an empty network and setting the internal structure of that.  This method is hence discouraged and will be deprecated later on.

~neural_net

#ifdef USE_VIRTUAL_DESTRUCTOR virtual #endif ~neural_net()

Provides automatic cleanup of data.  Define USE_VIRTUAL_DESTRUCTOR if you need the destructor to be virtual.

See also

destroy

destroy

void destroy()

Destructs the entire network.  Called automatically by the destructor.

See also

~neural_net

create_standard - DEPRECATED

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.

Parameters

num_layersThe total number of layers including the input and the output layer.
...Integer values determining the number of neurons in each layer starting with the input layer and ending with the output layer.

Returns

Boolean true if the network was created, false otherwise.

Example

const unsigned int num_layers = 3;
const unsigned int num_input = 2;
const unsigned int num_hidden = 3;
const unsigned int num_output = 1;

FANN::neural_net net;
net.create_standard(num_layers, num_input, num_hidden, num_output);

NOTE: As of version 2.3.0 it recommended to create neural networks using the constructors instead of creating an empty network and setting the internal structure of that.  This method is hence discouraged and will be deprecated later on.

See also

<create_standard_array>, <create_sparse>, <create_shortcut>, fann_create_standard_array

This function appears in FANN >= 2.0.0.

create_standard_array - DEPRECATED

Just like <create_standard>, but with an array of layer sizes instead of individual parameters.

NOTE: As of version 2.3.0 it recommended to create neural networks using the constructors instead of creating an empty network and setting the internal structure of that.  This method is hence discouraged and will be deprecated later on.

See also

<create_standard>, <create_sparse>, <create_shortcut>, fann_create_standard

This function appears in FANN >= 2.0.0.

create_sparse - DEPRECATED

Creates a standard backpropagation neural network, which is not fully connected.

Parameters

connection_rateThe connection rate controls how many connections there will be in the network.  If the connection rate is set to 1, the network will be fully connected, but if it is set to 0.5 only half of the connections will be set.  A connection rate of 1 will yield the same result as fann_create_standard
num_layersThe total number of layers including the input and the output layer.
...Integer values determining the number of neurons in each layer starting with the input layer and ending with the output layer.

Returns

Boolean true if the network was created, false otherwise.

NOTE: As of version 2.3.0 it recommended to create neural networks using the constructors instead of creating an empty network and setting the internal structure of that.  This method is hence discouraged and will be deprecated later on.

See also

<create_standard>, <create_sparse_array>, <create_shortcut>, fann_create_sparse

This function appears in FANN >= 2.0.0.

create_sparse_array - DEPRECATED

Just like <create_sparse>, but with an array of layer sizes instead of individual parameters.

See <create_sparse> for a description of the parameters.

NOTE: As of version 2.3.0 it recommended to create neural networks using the constructors instead of creating an empty network and setting the internal structure of that.  This method is hence discouraged and will be deprecated later on.

See also

<create_standard>, <create_sparse>, <create_shortcut>, fann_create_sparse_array

This function appears in FANN >= 2.0.0.

create_shortcut - DEPRECATED

Creates a standard backpropagation neural network, which is 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 <create_standard> for a description of the parameters.

NOTE: As of version 2.3.0 it recommended to create neural networks using the constructors instead of creating an empty network and setting the internal structure of that.  This method is hence discouraged and will be deprecated later on.

See also

<create_standard>, <create_sparse>, <create_shortcut_array>, fann_create_shortcut

This function appears in FANN >= 2.0.0.

create_shortcut_array - DEPRECATED

Just like <create_shortcut>, but with an array of layer sizes instead of individual parameters.

See <create_standard_array> for a description of the parameters.

NOTE: As of version 2.3.0 it recommended to create neural networks using the constructors instead of creating an empty network and setting the internal structure of that.  This method is hence discouraged and will be deprecated later on.

See also

<create_standard>, <create_sparse>, <create_shortcut>, fann_create_shortcut_array

This function appears in FANN >= 2.0.0.

run

fann_type *run(fann_type *input)

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.

See also

test, fann_run

This function appears in FANN >= 1.0.0.

randomize_weights

void randomize_weights(fann_type min_weight,
fann_type max_weight)

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 also

init_weights, fann_randomize_weights

This function appears in FANN >= 1.0.0.

init_weights

void init_weights(const training_data &data)

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 also

randomize_weights, training_data::read_train_from_file, fann_init_weights

This function appears in FANN >= 1.1.0.

print_connections

void 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
L   1 / N    3 BBa...
L   1 / N    4 BBA...
L   1 / N    5 ......
L   2 / N    6 ...BBA
L   2 / N    7 ......

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.

create_from_file - DEPRECATED

Constructs a backpropagation neural network from a configuration file, which have been saved by save.

NOTE: As of version 2.3.0 it recommended to create neural networks using the constructors instead of creating an empty network and setting the internal structure of that.  This method is hence discouraged and will be deprecated later on.

See also

save, save_to_fixed, fann_create_from_file

This function appears in FANN >= 1.0.0.

save

bool save(const std::string &configuration_file)

Save the entire network to a configuration file.

The configuration file contains all information about the neural network and enables <create_from_file> to create an exact copy of the neural network and all of the parameters associated with the neural network.

These two parameters (set_callback, set_error_log) are NOT saved to the file because they cannot safely be ported to a different location.  Also temporary parameters generated during training like get_MSE is not saved.

Return

The function returns 0 on success and -1 on failure.

See also

<create_from_file>, save_to_fixed, fann_save

This function appears in FANN >= 1.0.0.

save_to_fixed

int save_to_fixed(const std::string &configuration_file)

Saves the entire network to a configuration file.  But it is saved in fixed point format no matter which format it is currently in.

This is useful for training a network in floating points, and then later executing it in fixed point.

The function returns the bit position of the fix point, which can be used to find out how accurate the fixed point network will be.  A high value indicates high precision, and a low value indicates low precision.

A negative value indicates very low precision, and a very strong possibility for overflow.  (the actual fix point will be set to 0, since a negative fix point does not make sence).

Generally, a fix point lower than 6 is bad, and should be avoided.  The best way to avoid this, is to have less connections to each neuron, or just less neurons in each layer.

The fixed point use of this network is only intended for use on machines that have no floating point processor, like an iPAQ.  On normal computers the floating point version is actually faster.

See also

<create_from_file>, save, fann_save_to_fixed

This function appears in FANN >= 1.0.0.

train

void train(fann_type *input,
fann_type *desired_output)

Train one iteration with a set of inputs, and a set of desired outputs.  This training is always incremental training (see <FANN::training_algorithm_enum>), since only one pattern is presented.

Parameters

annThe neural network structure
inputan array of inputs.  This array must be exactly fann_get_num_input long.
desired_outputan array of desired outputs.  This array must be exactly fann_get_num_output long.

See also

train_on_data, train_epoch, fann_train

This function appears in FANN >= 1.0.0.

train_epoch

float train_epoch(const training_data &data)

Train one epoch with a set of training data.

Train one epoch with the training data stored in data.  One epoch is where all of the training data is considered exactly once.

This function returns the MSE error as it is calculated either before or during the actual training.  This is not the actual MSE after the training epoch, but since calculating this will require to go through the entire training set once more, it is more than adequate to use this value during training.

The training algorithm used by this function is chosen by the fann_set_training_algorithm function.

See also

train_on_data, test_data, fann_train_epoch

This function appears in FANN >= 1.2.0.

train_on_data

void train_on_data(const training_data &data,
unsigned int max_epochs,
unsigned int epochs_between_reports,
float desired_error)

Trains on an entire dataset, for a period of time.

This training uses the training algorithm chosen by set_training_algorithm, and the parameters set for these training algorithms.

Parameters

annThe neural network
dataThe data, which should be used during training
max_epochsThe maximum number of epochs the training should continue
epochs_between_reportsThe number of epochs between printing a status report to stdout.  A value of zero means no reports should be printed.
desired_errorThe desired get_MSE or get_bit_fail, depending on which stop function is chosen by set_train_stop_function.

Instead of printing out reports every epochs_between_reports, a callback function can be called (see set_callback).

See also

train_on_file, train_epoch, fann_train_on_data

This function appears in FANN >= 1.0.0.

train_on_file

void train_on_file(const std::string &filename,
unsigned int max_epochs,
unsigned int epochs_between_reports,
float desired_error)

Does the same as train_on_data, but reads the training data directly from a file.

See also

train_on_data, fann_train_on_file

This function appears in FANN >= 1.0.0.

test

fann_type *test(fann_type *input,
fann_type *desired_output)

Test with a set of inputs, and a set of desired outputs.  This operation updates the mean square error, but does not change the network in any way.

See also

test_data, train, fann_test

This function appears in FANN >= 1.0.0.

test_data

float test_data(const training_data &data)

Test a set of training data and calculates the MSE for the training data.

This function updates the MSE and the bit fail values.

See also

test, get_MSE, get_bit_fail, fann_test_data

This function appears in FANN >= 1.2.0.

get_MSE

float get_MSE()

Reads the mean square error from the network.

Reads the mean square error from the network.  This value is calculated during training or testing, and can therefore sometimes be a bit off if the weights have been changed since the last calculation of the value.

See also

test_data, fann_get_MSE

This function appears in FANN >= 1.1.0.

reset_MSE

void reset_MSE()

Resets the mean square error from the network.

This function also resets the number of bits that fail.

See also

get_MSE, get_bit_fail_limit, fann_reset_MSE

This function appears in FANN >= 1.1.0

set_callback

void set_callback(callback_type callback,
void *user_data)

Sets the callback function for use during training.  The user_data is passed to the callback.  It can point to arbitrary data that the callback might require and can be NULL if it is not used.

See <FANN::callback_type> for more information about the callback function.

The default callback function simply prints out some status information.

This function appears in FANN >= 2.0.0.

print_parameters

void print_parameters()

Prints all of the parameters and options of the neural network

See also

fann_print_parameters

This function appears in FANN >= 1.2.0.

get_training_algorithm

training_algorithm_enum get_training_algorithm()

Return the training algorithm as described by <FANN::training_algorithm_enum>.  This training algorithm is used by train_on_data and associated functions.

Note that this algorithm is also used during cascadetrain_on_data, although only FANN::TRAIN_RPROP and FANN::TRAIN_QUICKPROP is allowed during cascade training.

The default training algorithm is FANN::TRAIN_RPROP.

See also

set_training_algorithm, <FANN::training_algorithm_enum>, fann_get_training_algorithm

This function appears in FANN >= 1.0.0.

set_training_algorithm

void set_training_algorithm(training_algorithm_enum training_algorithm)

Set the training algorithm.

More info available in get_training_algorithm

This function appears in FANN >= 1.0.0.

get_learning_rate

float get_learning_rate()

Return the learning rate.

The learning rate is used to determine how aggressive training should be for some of the training algorithms (FANN::TRAIN_INCREMENTAL, FANN::TRAIN_BATCH, FANN::TRAIN_QUICKPROP).  Do however note that it is not used in FANN::TRAIN_RPROP.

The default learning rate is 0.7.

See also

set_learning_rate, set_training_algorithm, fann_get_learning_rate

This function appears in FANN >= 1.0.0.

set_learning_rate

void set_learning_rate(float learning_rate)

Set the learning rate.

More info available in get_learning_rate

This function appears in FANN >= 1.0.0.

get_activation_function

activation_function_enum get_activation_function(int layer,
int neuron)

Get the activation function for neuron number neuron in layer number layer, counting the input layer as layer 0.

It is not possible to get activation functions for the neurons in the input layer.

Information about the individual activation functions is available at <FANN::activation_function_enum>.

Returns

The activation function for the neuron or -1 if the neuron is not defined in the neural network.

See also

set_activation_function_layer, set_activation_function_hidden, set_activation_function_output, set_activation_steepness, set_activation_function, fann_get_activation_function

This function appears in FANN >= 2.1.0

set_activation_function

void set_activation_function(activation_function_enum activation_function,
int layer,
int neuron)

Set the activation function for neuron number neuron in layer number layer, counting the input layer as layer 0.

It is not possible to set activation functions for the neurons in the input layer.

When choosing an activation function it is important to note that the activation functions have different range.  FANN::SIGMOID is e.g. in the 0 - 1 range while FANN::SIGMOID_SYMMETRIC is in the -1 - 1 range and FANN::LINEAR is unbounded.

Information about the individual activation functions is available at <FANN::activation_function_enum>.

The default activation function is FANN::SIGMOID_STEPWISE.

See also

set_activation_function_layer, set_activation_function_hidden, set_activation_function_output, set_activation_steepness, get_activation_function, fann_set_activation_function

This function appears in FANN >= 2.0.0.

set_activation_function_layer

void set_activation_function_layer(
   activation_function_enum activation_function,
   int layer
)

Set the activation function for all the neurons in the layer number layer, counting the input layer as layer 0.

It is not possible to set activation functions for the neurons in the input layer.

See also

set_activation_function, set_activation_function_hidden, set_activation_function_output, set_activation_steepness_layer, fann_set_activation_function_layer

This function appears in FANN >= 2.0.0.

set_activation_function_hidden

void set_activation_function_hidden(
   activation_function_enum activation_function
)

Set the activation function for all of the hidden layers.

See also

set_activation_function, set_activation_function_layer, set_activation_function_output, set_activation_steepness_hidden, fann_set_activation_function_hidden

This function appears in FANN >= 1.0.0.

set_activation_function_output

void set_activation_function_output(
   activation_function_enum activation_function
)

Set the activation function for the output layer.

See also

set_activation_function, set_activation_function_layer, set_activation_function_hidden, set_activation_steepness_output, fann_set_activation_function_output

This function appears in FANN >= 1.0.0.

get_activation_steepness

fann_type get_activation_steepness(int layer,
int neuron)

Get the activation steepness for neuron number neuron in layer number layer, counting the input layer as layer 0.

It is not possible to get activation steepness for the neurons in the input layer.

The steepness of an activation function says something about how fast the activation function goes from the minimum to the maximum.  A high value for the activation function will also give a more aggressive training.

When training neural networks where the output values should be at the extremes (usually 0 and 1, depending on the activation function), a steep activation function can be used (e.g.  1.0).

The default activation steepness is 0.5.

Returns

The activation steepness for the neuron or -1 if the neuron is not defined in the neural network.

See also

set_activation_steepness_layer, set_activation_steepness_hidden, set_activation_steepness_output, set_activation_function, set_activation_steepness, fann_get_activation_steepness

This function appears in FANN >= 2.1.0

set_activation_steepness

void set_activation_steepness(fann_type steepness,
int layer,
int neuron)

Set the activation steepness for neuron number neuron in layer number layer, counting the input layer as layer 0.

It is not possible to set activation steepness for the neurons in the input layer.

The steepness of an activation function says something about how fast the activation function goes from the minimum to the maximum.  A high value for the activation function will also give a more aggressive training.

When training neural networks where the output values should be at the extremes (usually 0 and 1, depending on the activation function), a steep activation function can be used (e.g.  1.0).

The default activation steepness is 0.5.

See also

set_activation_steepness_layer, set_activation_steepness_hidden, set_activation_steepness_output, set_activation_function, get_activation_steepness, fann_set_activation_steepness

This function appears in FANN >= 2.0.0.

set_activation_steepness_layer

void set_activation_steepness_layer(fann_type steepness,
int layer)

Set the activation steepness all of the neurons in layer number layer, counting the input layer as layer 0.

It is not possible to set activation steepness for the neurons in the input layer.

See also

set_activation_steepness, set_activation_steepness_hidden, set_activation_steepness_output, set_activation_function_layer, fann_set_activation_steepness_layer

This function appears in FANN >= 2.0.0.

set_activation_steepness_hidden

void set_activation_steepness_hidden(fann_type steepness)

Set the steepness of the activation steepness in all of the hidden layers.

See also

set_activation_steepness, set_activation_steepness_layer, set_activation_steepness_output, set_activation_function_hidden, fann_set_activation_steepness_hidden

This function appears in FANN >= 1.2.0.

set_activation_steepness_output

void set_activation_steepness_output(fann_type steepness)

Set the steepness of the activation steepness in the output layer.

See also

set_activation_steepness, set_activation_steepness_layer, set_activation_steepness_hidden, set_activation_function_output, fann_set_activation_steepness_output

This function appears in FANN >= 1.2.0.

get_train_error_function

error_function_enum get_train_error_function()

Returns the error function used during training.

The error functions is described further in <FANN::error_function_enum>

The default error function is FANN::ERRORFUNC_TANH

See also

set_train_error_function, fann_get_train_error_function

This function appears in FANN >= 1.2.0.

set_train_error_function

void set_train_error_function(error_function_enum train_error_function)

Set the error function used during training.

The error functions is described further in <FANN::error_function_enum>

See also

get_train_error_function, fann_set_train_error_function

This function appears in FANN >= 1.2.0.

get_quickprop_decay

float get_quickprop_decay()

The decay is a small negative valued number which is the factor that the weights should become smaller in each iteration during quickprop training.  This is used to make sure that the weights do not become too high during training.

The default decay is -0.0001.

See also

set_quickprop_decay, fann_get_quickprop_decay

This function appears in FANN >= 1.2.0.

set_quickprop_decay

void set_quickprop_decay(float quickprop_decay)

Sets the quickprop decay factor.

See also

get_quickprop_decay, fann_set_quickprop_decay

This function appears in FANN >= 1.2.0.

get_quickprop_mu

float get_quickprop_mu()

The mu factor is used to increase and decrease the step-size during quickprop training.  The mu factor should always be above 1, since it would otherwise decrease the step-size when it was suppose to increase it.

The default mu factor is 1.75.

See also

set_quickprop_mu, fann_get_quickprop_mu

This function appears in FANN >= 1.2.0.

set_quickprop_mu

void set_quickprop_mu(float quickprop_mu)

Sets the quickprop mu factor.

See also

get_quickprop_mu, fann_set_quickprop_mu

This function appears in FANN >= 1.2.0.

get_rprop_increase_factor

float get_rprop_increase_factor()

The increase factor is a value larger than 1, which is used to increase the step-size during RPROP training.

The default increase factor is 1.2.

See also

set_rprop_increase_factor, fann_get_rprop_increase_factor

This function appears in FANN >= 1.2.0.

set_rprop_increase_factor

void set_rprop_increase_factor(float rprop_increase_factor)

The increase factor used during RPROP training.

See also

get_rprop_increase_factor, fann_set_rprop_increase_factor

This function appears in FANN >= 1.2.0.

get_rprop_decrease_factor

float get_rprop_decrease_factor()

The decrease factor is a value smaller than 1, which is used to decrease the step-size during RPROP training.

The default decrease factor is 0.5.

See also

set_rprop_decrease_factor, fann_get_rprop_decrease_factor

This function appears in FANN >= 1.2.0.

set_rprop_decrease_factor

void set_rprop_decrease_factor(float rprop_decrease_factor)

The decrease factor is a value smaller than 1, which is used to decrease the step-size during RPROP training.

See also

get_rprop_decrease_factor, fann_set_rprop_decrease_factor

This function appears in FANN >= 1.2.0.

get_rprop_delta_zero

float get_rprop_delta_zero()

The initial step-size is a small positive number determining how small the initial step-size may be.

The default value delta zero is 0.1.

See also

set_rprop_delta_zero, fann_get_rprop_delta_zero

This function appears in FANN >= 2.1.0.

set_rprop_delta_zero

void set_rprop_delta_zero(float rprop_delta_zero)

The initial step-size is a small positive number determining how small the initial step-size may be.

See also

get_rprop_delta_zero, fann_set_rprop_delta_zero

This function appears in FANN >= 2.1.0.

get_rprop_delta_min

float get_rprop_delta_min()

The minimum step-size is a small positive number determining how small the minimum step-size may be.

The default value delta min is 0.0.

See also

set_rprop_delta_min, fann_get_rprop_delta_min

This function appears in FANN >= 1.2.0.

set_rprop_delta_min

void set_rprop_delta_min(float rprop_delta_min)

The minimum step-size is a small positive number determining how small the minimum step-size may be.

See also

get_rprop_delta_min, fann_set_rprop_delta_min

This function appears in FANN >= 1.2.0.

get_rprop_delta_max

float get_rprop_delta_max()

The maximum step-size is a positive number determining how large the maximum step-size may be.

The default delta max is 50.0.

See also

set_rprop_delta_max, get_rprop_delta_min, fann_get_rprop_delta_max

This function appears in FANN >= 1.2.0.

set_rprop_delta_max

void set_rprop_delta_max(float rprop_delta_max)

The maximum step-size is a positive number determining how large the maximum step-size may be.

See also

get_rprop_delta_max, get_rprop_delta_min, fann_set_rprop_delta_max

This function appears in FANN >= 1.2.0.

get_sarprop_weight_decay_shift

float get_sarprop_weight_decay_shift()

The sarprop weight decay shift.

The default delta max is -6.644.

See also

set_sarprop_weight_decay_shift, <fann get_sarprop_weight_decay_shift>

This function appears in FANN >= 2.1.0.

set_sarprop_weight_decay_shift

void set_sarprop_weight_decay_shift(float sarprop_weight_decay_shift)

Set the sarprop weight decay shift.

This function appears in FANN >= 2.1.0.

See also

get_sarprop_weight_decay_shift, fann_set_sarprop_weight_decay_shift

get_sarprop_step_error_threshold_factor

float get_sarprop_step_error_threshold_factor()

The sarprop step error threshold factor.

The default delta max is 0.1.

See also

set_sarprop_step_error_threshold_factor, <fann get_sarprop_step_error_threshold_factor>

This function appears in FANN >= 2.1.0.

set_sarprop_step_error_threshold_factor

void set_sarprop_step_error_threshold_factor(
   float sarprop_step_error_threshold_factor
)

Set the sarprop step error threshold factor.

This function appears in FANN >= 2.1.0.

See also

get_sarprop_step_error_threshold_factor, fann_set_sarprop_step_error_threshold_factor

get_sarprop_step_error_shift

float get_sarprop_step_error_shift()

The get sarprop step error shift.

The default delta max is 1.385.

See also

set_sarprop_step_error_shift, <fann get_sarprop_step_error_shift>

This function appears in FANN >= 2.1.0.

set_sarprop_step_error_shift

void set_sarprop_step_error_shift(float sarprop_step_error_shift)

Set the sarprop step error shift.

This function appears in FANN >= 2.1.0.

See also

get_sarprop_step_error_shift, fann_set_sarprop_step_error_shift

get_sarprop_temperature

float get_sarprop_temperature()

The sarprop weight decay shift.

The default delta max is 0.015.

See also

set_sarprop_temperature, <fann get_sarprop_temperature>

This function appears in FANN >= 2.1.0.

set_sarprop_temperature

void set_sarprop_temperature(float sarprop_temperature)

Set the sarprop_temperature.

This function appears in FANN >= 2.1.0.

See also

get_sarprop_temperature, fann_set_sarprop_temperature

get_num_input

unsigned int get_num_input()

Get the number of input neurons.

This function appears in FANN >= 1.0.0.

get_num_output

unsigned int get_num_output()

Get the number of output neurons.

This function appears in FANN >= 1.0.0.

get_total_neurons

unsigned int get_total_neurons()

Get the total number of neurons in the entire network.  This number does also include the bias neurons, so a 2-4-2 network has 2+4+2 +2(bias) = 10 neurons.

This function appears in FANN >= 1.0.0.

get_total_connections

unsigned int get_total_connections()

Get the total number of connections in the entire network.

This function appears in FANN >= 1.0.0.

get_decimal_point

unsigned int 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>, get_multiplier, save_to_fixed, training_data::save_train_to_fixed, fann_get_decimal_point

This function appears in FANN >= 1.0.0.

get_multiplier

unsigned int 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>, get_decimal_point, save_to_fixed, training_data::save_train_to_fixed, fann_get_multiplier

This function appears in FANN >= 1.0.0.

get_network_type

network_type_enum get_network_type()

Get the type of neural network it was created as.

Returns

The neural network type from enum <FANN::network_type_enum>

See Also

fann_get_network_type

This function appears in FANN >= 2.1.0

get_connection_rate

float get_connection_rate()

Get the connection rate used when the network was created

Returns

The connection rate

See also

fann_get_connection_rate

This function appears in FANN >= 2.1.0

get_num_layers

unsigned int get_num_layers()

Get the number of layers in the network

Returns

The number of layers in the neural network

See also

fann_get_num_layers

This function appears in FANN >= 2.1.0

get_layer_array

void get_layer_array(unsigned int *layers)

Get the number of neurons in each layer in the network.

Bias is not included so the layers match the create methods.

The layers array must be preallocated to at least sizeof(unsigned int) * get_num_layers() long.

See also

fann_get_layer_array

This function appears in FANN >= 2.1.0

get_bias_array

void get_bias_array(unsigned int *bias)

Get the number of bias in each layer in the network.

The bias array must be preallocated to at least sizeof(unsigned int) * get_num_layers() long.

See also

fann_get_bias_array

This function appears in FANN >= 2.1.0

get_connection_array

void get_connection_array(connection *connections)

Get the connections in the network.

The connections array must be preallocated to at least sizeof(struct fann_connection) * get_total_connections() long.

See also

fann_get_connection_array

This function appears in FANN >= 2.1.0

set_weight_array

void set_weight_array(connection *connections,
unsigned int num_connections)

Set connections in the network.

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.

See also

fann_set_weight_array

This function appears in FANN >= 2.1.0

set_weight

void set_weight(unsigned int from_neuron,
unsigned int to_neuron,
fann_type weight)

Set a connection in the network.

Only the weights can be changed.  The connection/weight is ignored if it does not already exist in the network.

See also

fann_set_weight

This function appears in FANN >= 2.1.0

get_learning_momentum

float get_learning_momentum()

Get the learning momentum.

The learning momentum can be used to speed up FANN::TRAIN_INCREMENTAL training.  A too high momentum will however not benefit training.  Setting momentum to 0 will be the same as not using the momentum parameter.  The recommended value of this parameter is between 0.0 and 1.0.

The default momentum is 0.

See also

set_learning_momentum, set_training_algorithm

This function appears in FANN >= 2.0.0.

set_learning_momentum

void set_learning_momentum(float learning_momentum)

Set the learning momentum.

More info available in get_learning_momentum

This function appears in FANN >= 2.0.0.

get_train_stop_function

stop_function_enum get_train_stop_function()

Returns the the stop function used during training.

The stop function is described further in <FANN::stop_function_enum>

The default stop function is FANN::STOPFUNC_MSE

See also

get_train_stop_function, get_bit_fail_limit

This function appears in FANN >= 2.0.0.

set_train_stop_function

void set_train_stop_function(stop_function_enum train_stop_function)

Set the stop function used during training.

The stop function is described further in <FANN::stop_function_enum>

See also

get_train_stop_function

This function appears in FANN >= 2.0.0.

get_bit_fail_limit

fann_type get_bit_fail_limit()

Returns the bit fail limit used during training.

The bit fail limit is used during training when the <FANN::stop_function_enum> is set to FANN_STOPFUNC_BIT.

The limit is the maximum accepted difference between the desired output and the actual output during training.  Each output that diverges more than this limit is counted as an error bit.  This difference is divided by two when dealing with symmetric activation functions, so that symmetric and not symmetric activation functions can use the same limit.

The default bit fail limit is 0.35.

See also

set_bit_fail_limit

This function appears in FANN >= 2.0.0.

set_bit_fail_limit

void set_bit_fail_limit(fann_type bit_fail_limit)

Set the bit fail limit used during training.

See also

get_bit_fail_limit

This function appears in FANN >= 2.0.0.

get_bit_fail

unsigned int get_bit_fail()

The number of fail bits; means the number of output neurons which differ more than the bit fail limit (see get_bit_fail_limit, set_bit_fail_limit).  The bits are counted in all of the training data, so this number can be higher than the number of training data.

This value is reset by reset_MSE and updated by all the same functions which also updates the MSE value (e.g.  test_data, train_epoch)

See also

<FANN::stop_function_enum>, get_MSE

This function appears in FANN >= 2.0.0

cascadetrain_on_data

void cascadetrain_on_data(const training_data &data,
unsigned int max_neurons,
unsigned int neurons_between_reports,
float desired_error)

Trains on an entire dataset, for a period of time using the Cascade2 training algorithm.  This algorithm adds neurons to the neural network while training, which means that it needs to start with an ANN without any hidden layers.  The neural network should also use shortcut connections, so <create_shortcut> should be used to create the ANN like this:

net.create_shortcut(2, train_data.num_input_train_data(), train_data.num_output_train_data());

This training uses the parameters set using the set_cascade_..., but it also uses another training algorithm as it’s internal training algorithm.  This algorithm can be set to either FANN::TRAIN_RPROP or FANN::TRAIN_QUICKPROP by set_training_algorithm, and the parameters set for these training algorithms will also affect the cascade training.

Parameters

dataThe data, which should be used during training
max_neuronThe maximum number of neurons to be added to neural network
neurons_between_reportsThe number of neurons between printing a status report to stdout.  A value of zero means no reports should be printed.
desired_errorThe desired fann_get_MSE or fann_get_bit_fail, depending on which stop function is chosen by fann_set_train_stop_function.

Instead of printing out reports every neurons_between_reports, a callback function can be called (see set_callback).

See also

train_on_data, cascadetrain_on_file, fann_cascadetrain_on_data

This function appears in FANN >= 2.0.0.

cascadetrain_on_file

void cascadetrain_on_file(const std::string &filename,
unsigned int max_neurons,
unsigned int neurons_between_reports,
float desired_error)

Does the same as cascadetrain_on_data, but reads the training data directly from a file.

See also

fann_cascadetrain_on_data, fann_cascadetrain_on_file

This function appears in FANN >= 2.0.0.

get_cascade_output_change_fraction

float get_cascade_output_change_fraction()

The cascade output change fraction is a number between 0 and 1 determining how large a fraction the get_MSE value should change within get_cascade_output_stagnation_epochs during training of the output connections, in order for the training not to stagnate.  If the training stagnates, the training of the output connections will be ended and new candidates will be prepared.

This means

If the MSE does not change by a fraction of get_cascade_output_change_fraction during a period of get_cascade_output_stagnation_epochs, the training of the output connections is stopped because the training has stagnated.

If the cascade output change fraction is low, the output connections will be trained more and if the fraction is high they will be trained less.

The default cascade output change fraction is 0.01, which is equalent to a 1% change in MSE.

See also

set_cascade_output_change_fraction, get_MSE, get_cascade_output_stagnation_epochs, fann_get_cascade_output_change_fraction

This function appears in FANN >= 2.0.0.

set_cascade_output_change_fraction

void set_cascade_output_change_fraction(float cascade_output_change_fraction)

Sets the cascade output change fraction.

See also

get_cascade_output_change_fraction, fann_set_cascade_output_change_fraction

This function appears in FANN >= 2.0.0.

get_cascade_output_stagnation_epochs

unsigned int get_cascade_output_stagnation_epochs()

The number of cascade output stagnation epochs determines the number of epochs training is allowed to continue without changing the MSE by a fraction of get_cascade_output_change_fraction.

See more info about this parameter in get_cascade_output_change_fraction.

The default number of cascade output stagnation epochs is 12.

See also

set_cascade_output_stagnation_epochs, get_cascade_output_change_fraction, fann_get_cascade_output_stagnation_epochs

This function appears in FANN >= 2.0.0.

set_cascade_output_stagnation_epochs

void set_cascade_output_stagnation_epochs(
   unsigned int cascade_output_stagnation_epochs
)

Sets the number of cascade output stagnation epochs.

See also

get_cascade_output_stagnation_epochs, fann_set_cascade_output_stagnation_epochs

This function appears in FANN >= 2.0.0.

get_cascade_candidate_change_fraction

float get_cascade_candidate_change_fraction()

The cascade candidate change fraction is a number between 0 and 1 determining how large a fraction the get_MSE value should change within get_cascade_candidate_stagnation_epochs during training of the candidate neurons, in order for the training not to stagnate.  If the training stagnates, the training of the candidate neurons will be ended and the best candidate will be selected.

This means

If the MSE does not change by a fraction of get_cascade_candidate_change_fraction during a period of get_cascade_candidate_stagnation_epochs, the training of the candidate neurons is stopped because the training has stagnated.

If the cascade candidate change fraction is low, the candidate neurons will be trained more and if the fraction is high they will be trained less.

The default cascade candidate change fraction is 0.01, which is equalent to a 1% change in MSE.

See also

set_cascade_candidate_change_fraction, get_MSE, get_cascade_candidate_stagnation_epochs, fann_get_cascade_candidate_change_fraction

This function appears in FANN >= 2.0.0.

set_cascade_candidate_change_fraction

void set_cascade_candidate_change_fraction(
   float cascade_candidate_change_fraction
)

Sets the cascade candidate change fraction.

See also

get_cascade_candidate_change_fraction, fann_set_cascade_candidate_change_fraction

This function appears in FANN >= 2.0.0.

get_cascade_candidate_stagnation_epochs

unsigned int get_cascade_candidate_stagnation_epochs()

The number of cascade candidate stagnation epochs determines the number of epochs training is allowed to continue without changing the MSE by a fraction of get_cascade_candidate_change_fraction.

See more info about this parameter in get_cascade_candidate_change_fraction.

The default number of cascade candidate stagnation epochs is 12.

See also

set_cascade_candidate_stagnation_epochs, get_cascade_candidate_change_fraction, fann_get_cascade_candidate_stagnation_epochs

This function appears in FANN >= 2.0.0.

set_cascade_candidate_stagnation_epochs

void set_cascade_candidate_stagnation_epochs(
   unsigned int cascade_candidate_stagnation_epochs
)

Sets the number of cascade candidate stagnation epochs.

See also

get_cascade_candidate_stagnation_epochs, fann_set_cascade_candidate_stagnation_epochs

This function appears in FANN >= 2.0.0.

get_cascade_weight_multiplier

fann_type get_cascade_weight_multiplier()

The weight multiplier is a parameter which is used to multiply the weights from the candidate neuron before adding the neuron to the neural network.  This parameter is usually between 0 and 1, and is used to make the training a bit less aggressive.

The default weight multiplier is 0.4

See also

set_cascade_weight_multiplier, fann_get_cascade_weight_multiplier

This function appears in FANN >= 2.0.0.

set_cascade_weight_multiplier

void set_cascade_weight_multiplier(fann_type cascade_weight_multiplier)

Sets the weight multiplier.

See also

get_cascade_weight_multiplier, fann_set_cascade_weight_multiplier

This function appears in FANN >= 2.0.0.

get_cascade_candidate_limit

fann_type get_cascade_candidate_limit()

The candidate limit is a limit for how much the candidate neuron may be trained.  The limit is a limit on the proportion between the MSE and candidate score.

Set this to a lower value to avoid overfitting and to a higher if overfitting is not a problem.

The default candidate limit is 1000.0

See also

set_cascade_candidate_limit, fann_get_cascade_candidate_limit

This function appears in FANN >= 2.0.0.

set_cascade_candidate_limit

void set_cascade_candidate_limit(fann_type cascade_candidate_limit)

Sets the candidate limit.

See also

get_cascade_candidate_limit, fann_set_cascade_candidate_limit

This function appears in FANN >= 2.0.0.

get_cascade_max_out_epochs

unsigned int get_cascade_max_out_epochs()

The maximum out epochs determines the maximum number of epochs the output connections may be trained after adding a new candidate neuron.

The default max out epochs is 150

See also

set_cascade_max_out_epochs, fann_get_cascade_max_out_epochs

This function appears in FANN >= 2.0.0.

set_cascade_max_out_epochs

void set_cascade_max_out_epochs(unsigned int cascade_max_out_epochs)

Sets the maximum out epochs.

See also

get_cascade_max_out_epochs, fann_set_cascade_max_out_epochs

This function appears in FANN >= 2.0.0.

get_cascade_max_cand_epochs

unsigned int get_cascade_max_cand_epochs()

The maximum candidate epochs determines the maximum number of epochs the input connections to the candidates may be trained before adding a new candidate neuron.

The default max candidate epochs is 150

See also

set_cascade_max_cand_epochs, fann_get_cascade_max_cand_epochs

This function appears in FANN >= 2.0.0.

set_cascade_max_cand_epochs

void set_cascade_max_cand_epochs(unsigned int cascade_max_cand_epochs)

Sets the max candidate epochs.

See also

get_cascade_max_cand_epochs, fann_set_cascade_max_cand_epochs

This function appears in FANN >= 2.0.0.

get_cascade_num_candidates

unsigned int get_cascade_num_candidates()

The number of candidates used during training (calculated by multiplying get_cascade_activation_functions_count, get_cascade_activation_steepnesses_count and get_cascade_num_candidate_groups).

The actual candidates is defined by the get_cascade_activation_functions and get_cascade_activation_steepnesses arrays.  These arrays define the activation functions and activation steepnesses used for the candidate neurons.  If there are 2 activation functions in the activation function array and 3 steepnesses in the steepness array, then there will be 2x3=6 different candidates which will be trained.  These 6 different candidates can be copied into several candidate groups, where the only difference between these groups is the initial weights.  If the number of groups is set to 2, then the number of candidate neurons will be 2x3x2=12.  The number of candidate groups is defined by set_cascade_num_candidate_groups.

The default number of candidates is 6x4x2 = 48

See also

get_cascade_activation_functions, get_cascade_activation_functions_count, get_cascade_activation_steepnesses, get_cascade_activation_steepnesses_count, get_cascade_num_candidate_groups, fann_get_cascade_num_candidates

This function appears in FANN >= 2.0.0.

get_cascade_activation_functions_count

unsigned int get_cascade_activation_functions_count()

The number of activation functions in the get_cascade_activation_functions array.

The default number of activation functions is 10.

See also

get_cascade_activation_functions, set_cascade_activation_functions, fann_get_cascade_activation_functions_count

This function appears in FANN >= 2.0.0.

get_cascade_activation_functions

activation_function_enum *get_cascade_activation_functions()

The cascade activation functions array is an array of the different activation functions used by the candidates.

See get_cascade_num_candidates for a description of which candidate neurons will be generated by this array.

See also

get_cascade_activation_functions_count, set_cascade_activation_functions, <FANN::activation_function_enum>

This function appears in FANN >= 2.0.0.

set_cascade_activation_functions

void set_cascade_activation_functions(
   activation_function_enum *cascade_activation_functions,
   unsigned int cascade_activation_functions_count
)

Sets the array of cascade candidate activation functions.  The array must be just as long as defined by the count.

See get_cascade_num_candidates for a description of which candidate neurons will be generated by this array.

See also

get_cascade_activation_steepnesses_count, get_cascade_activation_steepnesses, fann_set_cascade_activation_functions

This function appears in FANN >= 2.0.0.

get_cascade_activation_steepnesses_count

unsigned int get_cascade_activation_steepnesses_count()

The number of activation steepnesses in the get_cascade_activation_functions array.

The default number of activation steepnesses is 4.

See also

get_cascade_activation_steepnesses, set_cascade_activation_functions, fann_get_cascade_activation_steepnesses_count

This function appears in FANN >= 2.0.0.

get_cascade_activation_steepnesses

fann_type *get_cascade_activation_steepnesses()

The cascade activation steepnesses array is an array of the different activation functions used by the candidates.

See get_cascade_num_candidates for a description of which candidate neurons will be generated by this array.

The default activation steepnesses is {0.25, 0.50, 0.75, 1.00}

See also

set_cascade_activation_steepnesses, get_cascade_activation_steepnesses_count, fann_get_cascade_activation_steepnesses

This function appears in FANN >= 2.0.0.

set_cascade_activation_steepnesses

void set_cascade_activation_steepnesses(
   fann_type *cascade_activation_steepnesses,
   unsigned int cascade_activation_steepnesses_count
)

Sets the array of cascade candidate activation steepnesses.  The array must be just as long as defined by the count.

See get_cascade_num_candidates for a description of which candidate neurons will be generated by this array.

See also

get_cascade_activation_steepnesses, get_cascade_activation_steepnesses_count, fann_set_cascade_activation_steepnesses

This function appears in FANN >= 2.0.0.

get_cascade_num_candidate_groups

unsigned int get_cascade_num_candidate_groups()

The number of candidate groups is the number of groups of identical candidates which will be used during training.

This number can be used to have more candidates without having to define new parameters for the candidates.

See get_cascade_num_candidates for a description of which candidate neurons will be generated by this parameter.

The default number of candidate groups is 2

See also

set_cascade_num_candidate_groups, fann_get_cascade_num_candidate_groups

This function appears in FANN >= 2.0.0.

set_cascade_num_candidate_groups

void set_cascade_num_candidate_groups(
   unsigned int cascade_num_candidate_groups
)

Sets the number of candidate groups.

See also

get_cascade_num_candidate_groups, fann_set_cascade_num_candidate_groups

This function appears in FANN >= 2.0.0.

scale_train

void scale_train(training_data &data)

Scale input and output data based on previously calculated parameters.

See also

descale_train, fann_scale_train

This function appears in FANN >= 2.1.0.

descale_train

void descale_train(training_data &data)

Descale input and output data based on previously calculated parameters.

See also

scale_train, fann_descale_train

This function appears in FANN >= 2.1.0.

set_input_scaling_params

bool set_input_scaling_params(const training_data &data,
float new_input_min,
float new_input_max)

Calculate scaling parameters for future use based on training data.

See also

set_output_scaling_params, fann_set_input_scaling_params

This function appears in FANN >= 2.1.0.

set_output_scaling_params

bool set_output_scaling_params(const training_data &data,
float new_output_min,
float new_output_max)

Calculate scaling parameters for future use based on training data.

See also

set_input_scaling_params, fann_set_output_scaling_params

This function appears in FANN >= 2.1.0.

set_scaling_params

bool set_scaling_params(const training_data &data,
float new_input_min,
float new_input_max,
float new_output_min,
float new_output_max)

Calculate scaling parameters for future use based on training data.

See also

clear_scaling_params, fann_set_scaling_params

This function appears in FANN >= 2.1.0.

clear_scaling_params

bool clear_scaling_params()

Clears scaling parameters.

See also

set_scaling_params, fann_clear_scaling_params

This function appears in FANN >= 2.1.0.

scale_input

void scale_input(fann_type *input_vector)

Scale data in input vector before feed it to ann based on previously calculated parameters.

See also

descale_input, scale_output, fann_scale_input

This function appears in FANN >= 2.1.0.

scale_output

void scale_output(fann_type *output_vector)

Scale data in output vector before feed it to ann based on previously calculated parameters.

See also

descale_output, scale_input, fann_scale_output

This function appears in FANN >= 2.1.0.

descale_input

void descale_input(fann_type *input_vector)

Scale data in input vector after get it from ann based on previously calculated parameters.

See also

scale_input, descale_output, fann_descale_input

This function appears in FANN >= 2.1.0.

descale_output

void descale_output(fann_type *output_vector)

Scale data in output vector after get it from ann based on previously calculated parameters.

See also

scale_output, descale_input, fann_descale_output

This function appears in FANN >= 2.1.0.

set_error_log

void set_error_log(FILE *log_file)

Change where errors are logged to.

If log_file is NULL, no errors will be printed.

If neural_net is empty i.e. ann is NULL, the default log will be set.  The default log is the log used when creating a neural_net.  This default log will also be the default for all new structs that are created.

The default behavior is to log them to stderr.

See also

struct fann_error, fann_set_error_log

This function appears in FANN >= 1.1.0.

get_errno

unsigned int get_errno()

Returns the last error number.

See also

fann_errno_enum, fann_reset_errno, fann_get_errno

This function appears in FANN >= 1.1.0.

reset_errno

void reset_errno()

Resets the last error number.

This function appears in FANN >= 1.1.0.

reset_errstr

void reset_errstr()

Resets the last error string.

This function appears in FANN >= 1.1.0.

get_errstr

std::string get_errstr()

Returns the last errstr.

This function calls fann_reset_errno and fann_reset_errstr

This function appears in FANN >= 1.1.0.

print_error

void print_error()

Prints the last error to stderr.

This function appears in FANN >= 1.1.0.

disable_seed_rand

void disable_seed_rand()

Disables the automatic random generator seeding that happens in FANN.

Per default FANN will always seed the random generator when creating a new network, unless FANN_NO_SEED is defined during compilation of the library.  This method can disable this at runtime.

This function appears in FANN >= 2.3.0

enable_seed_rand

void enable_seed_rand()

Enables the automatic random generator seeding that happens in FANN.

Per default FANN will always seed the random generator when creating a new network, unless FANN_NO_SEED is defined during compilation of the library.  This method can disable this at runtime.

This function appears in FANN >= 2.3.0

class neural_net
neural_net is the main neural network class used for both training and execution
class training_data
training_data is used to create and manipulate training data used by the neural_net
namespace FANN
The FANN namespace groups the C++ wrapper definitions
neural_net(network_type_enum net_type,
unsigned int num_layers,
const unsigned int *layers)
Creates a neural network of the desired network_type_enum net_type, based on array of layers.
Definition of network types used by neural_net::get_network_type
template <class InputIterator> neural_net(network_type_enum net_type,
InputIterator layersBeginIterator,
InputIterator layersEndIterator)
Creates a neural network of the desired network_type_enum net_type, based on iterator to the layers.
neural_net(network_type_enum net_type,
unsigned int num_layers,
 ...)
Creates a neural network of the desired network_type_enum net_type.
neural_net(float connection_rate,
unsigned int num_layers,
 ...)
Creates a standard backpropagation neural network, which is sparsely connected, this will default the network_type_enum to LAYER
Each layer only has connections to the next layer
neural_net(float connection_rate,
unsigned int num_layers,
const unsigned int *layers)
Creates a standard backpropagation neural network, which is sparsely connected, this will default the network_type_enum to LAYER
neural_net(const std::string &configuration_file)
Constructs a backpropagation neural network from a configuration file, which have been saved by save.
bool save(const std::string &configuration_file)
Save the entire network to a configuration file.
neural_net(struct fann *other)
Creates a copy the other neural_net.
neural_net() : ann(NULL)
Creates an empty neural net.
#ifdef USE_VIRTUAL_DESTRUCTOR virtual #endif ~neural_net()
Provides automatic cleanup of data.
void destroy()
Destructs the entire network.
fann_type *run(fann_type *input)
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.
void randomize_weights(fann_type min_weight,
fann_type max_weight)
Give each connection a random weight between min_weight and max_weight
void init_weights(const training_data &data)
Initialize the weights using Widrow + Nguyen’s algorithm.
void print_connections()
Will print the connections of the ann in a compact matrix, for easy viewing of the internals of the ann.
int save_to_fixed(const std::string &configuration_file)
Saves the entire network to a configuration file.
void train(fann_type *input,
fann_type *desired_output)
Train one iteration with a set of inputs, and a set of desired outputs.
float train_epoch(const training_data &data)
Train one epoch with a set of training data.
void train_on_data(const training_data &data,
unsigned int max_epochs,
unsigned int epochs_between_reports,
float desired_error)
Trains on an entire dataset, for a period of time.
void train_on_file(const std::string &filename,
unsigned int max_epochs,
unsigned int epochs_between_reports,
float desired_error)
Does the same as train_on_data, but reads the training data directly from a file.
fann_type *test(fann_type *input,
fann_type *desired_output)
Test with a set of inputs, and a set of desired outputs.
float test_data(const training_data &data)
Test a set of training data and calculates the MSE for the training data.
float get_MSE()
Reads the mean square error from the network.
void reset_MSE()
Resets the mean square error from the network.
void set_callback(callback_type callback,
void *user_data)
Sets the callback function for use during training.
void print_parameters()
Prints all of the parameters and options of the neural network
training_algorithm_enum get_training_algorithm()
Return the training algorithm as described by FANN::training_algorithm_enum.
void set_training_algorithm(training_algorithm_enum training_algorithm)
Set the training algorithm.
float get_learning_rate()
Return the learning rate.
void set_learning_rate(float learning_rate)
Set the learning rate.
activation_function_enum get_activation_function(int layer,
int neuron)
Get the activation function for neuron number neuron in layer number layer, counting the input layer as layer 0.
void set_activation_function(activation_function_enum activation_function,
int layer,
int neuron)
Set the activation function for neuron number neuron in layer number layer, counting the input layer as layer 0.
void set_activation_function_layer(
   activation_function_enum activation_function,
   int layer
)
Set the activation function for all the neurons in the layer number layer, counting the input layer as layer 0.
void set_activation_function_hidden(
   activation_function_enum activation_function
)
Set the activation function for all of the hidden layers.
void set_activation_function_output(
   activation_function_enum activation_function
)
Set the activation function for the output layer.
fann_type get_activation_steepness(int layer,
int neuron)
Get the activation steepness for neuron number neuron in layer number layer, counting the input layer as layer 0.
void set_activation_steepness(fann_type steepness,
int layer,
int neuron)
Set the activation steepness for neuron number neuron in layer number layer, counting the input layer as layer 0.
void set_activation_steepness_layer(fann_type steepness,
int layer)
Set the activation steepness all of the neurons in layer number layer, counting the input layer as layer 0.
void set_activation_steepness_hidden(fann_type steepness)
Set the steepness of the activation steepness in all of the hidden layers.
void set_activation_steepness_output(fann_type steepness)
Set the steepness of the activation steepness in the output layer.
error_function_enum get_train_error_function()
Returns the error function used during training.
void set_train_error_function(error_function_enum train_error_function)
Set the error function used during training.
float get_quickprop_decay()
The decay is a small negative valued number which is the factor that the weights should become smaller in each iteration during quickprop training.
void set_quickprop_decay(float quickprop_decay)
Sets the quickprop decay factor.
float get_quickprop_mu()
The mu factor is used to increase and decrease the step-size during quickprop training.
void set_quickprop_mu(float quickprop_mu)
Sets the quickprop mu factor.
float get_rprop_increase_factor()
The increase factor is a value larger than 1, which is used to increase the step-size during RPROP training.
void set_rprop_increase_factor(float rprop_increase_factor)
The increase factor used during RPROP training.
float get_rprop_decrease_factor()
The decrease factor is a value smaller than 1, which is used to decrease the step-size during RPROP training.
void set_rprop_decrease_factor(float rprop_decrease_factor)
The decrease factor is a value smaller than 1, which is used to decrease the step-size during RPROP training.
float get_rprop_delta_zero()
The initial step-size is a small positive number determining how small the initial step-size may be.
void set_rprop_delta_zero(float rprop_delta_zero)
The initial step-size is a small positive number determining how small the initial step-size may be.
float get_rprop_delta_min()
The minimum step-size is a small positive number determining how small the minimum step-size may be.
void set_rprop_delta_min(float rprop_delta_min)
The minimum step-size is a small positive number determining how small the minimum step-size may be.
float get_rprop_delta_max()
The maximum step-size is a positive number determining how large the maximum step-size may be.
void set_rprop_delta_max(float rprop_delta_max)
The maximum step-size is a positive number determining how large the maximum step-size may be.
float get_sarprop_weight_decay_shift()
The sarprop weight decay shift.
void set_sarprop_weight_decay_shift(float sarprop_weight_decay_shift)
Set the sarprop weight decay shift.
float get_sarprop_step_error_threshold_factor()
The sarprop step error threshold factor.
void set_sarprop_step_error_threshold_factor(
   float sarprop_step_error_threshold_factor
)
Set the sarprop step error threshold factor.
float get_sarprop_step_error_shift()
The get sarprop step error shift.
void set_sarprop_step_error_shift(float sarprop_step_error_shift)
Set the sarprop step error shift.
float get_sarprop_temperature()
The sarprop weight decay shift.
void set_sarprop_temperature(float sarprop_temperature)
Set the sarprop_temperature.
unsigned int get_num_input()
Get the number of input neurons.
unsigned int get_num_output()
Get the number of output neurons.
unsigned int get_total_neurons()
Get the total number of neurons in the entire network.
unsigned int get_total_connections()
Get the total number of connections in the entire network.
unsigned int get_decimal_point()
Returns the position of the decimal point in the ann.
unsigned int get_multiplier()
Returns the multiplier that fix point data is multiplied with.
network_type_enum get_network_type()
Get the type of neural network it was created as.
float get_connection_rate()
Get the connection rate used when the network was created
unsigned int get_num_layers()
Get the number of layers in the network
void get_layer_array(unsigned int *layers)
Get the number of neurons in each layer in the network.
void get_bias_array(unsigned int *bias)
Get the number of bias in each layer in the network.
void get_connection_array(connection *connections)
Get the connections in the network.
void set_weight_array(connection *connections,
unsigned int num_connections)
Set connections in the network.
void set_weight(unsigned int from_neuron,
unsigned int to_neuron,
fann_type weight)
Set a connection in the network.
float get_learning_momentum()
Get the learning momentum.
void set_learning_momentum(float learning_momentum)
Set the learning momentum.
stop_function_enum get_train_stop_function()
Returns the the stop function used during training.
void set_train_stop_function(stop_function_enum train_stop_function)
Set the stop function used during training.
fann_type get_bit_fail_limit()
Returns the bit fail limit used during training.
void set_bit_fail_limit(fann_type bit_fail_limit)
Set the bit fail limit used during training.
unsigned int get_bit_fail()
The number of fail bits; means the number of output neurons which differ more than the bit fail limit (see get_bit_fail_limit, set_bit_fail_limit).
void cascadetrain_on_data(const training_data &data,
unsigned int max_neurons,
unsigned int neurons_between_reports,
float desired_error)
Trains on an entire dataset, for a period of time using the Cascade2 training algorithm.
void cascadetrain_on_file(const std::string &filename,
unsigned int max_neurons,
unsigned int neurons_between_reports,
float desired_error)
Does the same as cascadetrain_on_data, but reads the training data directly from a file.
float get_cascade_output_change_fraction()
The cascade output change fraction is a number between 0 and 1 determining how large a fraction the get_MSE value should change within get_cascade_output_stagnation_epochs during training of the output connections, in order for the training not to stagnate.
unsigned int get_cascade_output_stagnation_epochs()
The number of cascade output stagnation epochs determines the number of epochs training is allowed to continue without changing the MSE by a fraction of get_cascade_output_change_fraction.
void set_cascade_output_change_fraction(float cascade_output_change_fraction)
Sets the cascade output change fraction.
void set_cascade_output_stagnation_epochs(
   unsigned int cascade_output_stagnation_epochs
)
Sets the number of cascade output stagnation epochs.
float get_cascade_candidate_change_fraction()
The cascade candidate change fraction is a number between 0 and 1 determining how large a fraction the get_MSE value should change within get_cascade_candidate_stagnation_epochs during training of the candidate neurons, in order for the training not to stagnate.
unsigned int get_cascade_candidate_stagnation_epochs()
The number of cascade candidate stagnation epochs determines the number of epochs training is allowed to continue without changing the MSE by a fraction of get_cascade_candidate_change_fraction.
void set_cascade_candidate_change_fraction(
   float cascade_candidate_change_fraction
)
Sets the cascade candidate change fraction.
void set_cascade_candidate_stagnation_epochs(
   unsigned int cascade_candidate_stagnation_epochs
)
Sets the number of cascade candidate stagnation epochs.
fann_type get_cascade_weight_multiplier()
The weight multiplier is a parameter which is used to multiply the weights from the candidate neuron before adding the neuron to the neural network.
void set_cascade_weight_multiplier(fann_type cascade_weight_multiplier)
Sets the weight multiplier.
fann_type get_cascade_candidate_limit()
The candidate limit is a limit for how much the candidate neuron may be trained.
void set_cascade_candidate_limit(fann_type cascade_candidate_limit)
Sets the candidate limit.
unsigned int get_cascade_max_out_epochs()
The maximum out epochs determines the maximum number of epochs the output connections may be trained after adding a new candidate neuron.
void set_cascade_max_out_epochs(unsigned int cascade_max_out_epochs)
Sets the maximum out epochs.
unsigned int get_cascade_max_cand_epochs()
The maximum candidate epochs determines the maximum number of epochs the input connections to the candidates may be trained before adding a new candidate neuron.
void set_cascade_max_cand_epochs(unsigned int cascade_max_cand_epochs)
Sets the max candidate epochs.
unsigned int get_cascade_num_candidates()
The number of candidates used during training (calculated by multiplying get_cascade_activation_functions_count, get_cascade_activation_steepnesses_count and get_cascade_num_candidate_groups).
unsigned int get_cascade_activation_functions_count()
The number of activation functions in the get_cascade_activation_functions array.
unsigned int get_cascade_activation_steepnesses_count()
The number of activation steepnesses in the get_cascade_activation_functions array.
unsigned int get_cascade_num_candidate_groups()
The number of candidate groups is the number of groups of identical candidates which will be used during training.
activation_function_enum *get_cascade_activation_functions()
The cascade activation functions array is an array of the different activation functions used by the candidates.
void set_cascade_activation_functions(
   activation_function_enum *cascade_activation_functions,
   unsigned int cascade_activation_functions_count
)
Sets the array of cascade candidate activation functions.
fann_type *get_cascade_activation_steepnesses()
The cascade activation steepnesses array is an array of the different activation functions used by the candidates.
void set_cascade_activation_steepnesses(
   fann_type *cascade_activation_steepnesses,
   unsigned int cascade_activation_steepnesses_count
)
Sets the array of cascade candidate activation steepnesses.
void set_cascade_num_candidate_groups(
   unsigned int cascade_num_candidate_groups
)
Sets the number of candidate groups.
void scale_train(training_data &data)
Scale input and output data based on previously calculated parameters.
void descale_train(training_data &data)
Descale input and output data based on previously calculated parameters.
bool set_input_scaling_params(const training_data &data,
float new_input_min,
float new_input_max)
Calculate scaling parameters for future use based on training data.
bool set_output_scaling_params(const training_data &data,
float new_output_min,
float new_output_max)
Calculate scaling parameters for future use based on training data.
bool set_scaling_params(const training_data &data,
float new_input_min,
float new_input_max,
float new_output_min,
float new_output_max)
Calculate scaling parameters for future use based on training data.
bool clear_scaling_params()
Clears scaling parameters.
void scale_input(fann_type *input_vector)
Scale data in input vector before feed it to ann based on previously calculated parameters.
void scale_output(fann_type *output_vector)
Scale data in output vector before feed it to ann based on previously calculated parameters.
void descale_input(fann_type *input_vector)
Scale data in input vector after get it from ann based on previously calculated parameters.
void descale_output(fann_type *output_vector)
Scale data in output vector after get it from ann based on previously calculated parameters.
void set_error_log(FILE *log_file)
Change where errors are logged to.
unsigned int get_errno()
Returns the last error number.
void reset_errno()
Resets the last error number.
void reset_errstr()
Resets the last error string.
std::string get_errstr()
Returns the last errstr.
void print_error()
Prints the last error to stderr.
void disable_seed_rand()
Disables the automatic random generator seeding that happens in FANN.
void enable_seed_rand()
Enables the automatic random generator seeding that happens in FANN.
struct fann
The fast artificial neural network (fann) structure.
FANN_EXTERNAL struct fann *FANN_API fann_create_standard(
   unsigned int num_layers,
    ...
)
Creates a standard fully connected backpropagation neural network.
FANN_EXTERNAL struct fann *FANN_API fann_create_standard_array(
   unsigned int num_layers,
   const unsigned int *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_sparse(
   float connection_rate,
   unsigned int num_layers,
    ...
)
Creates a standard backpropagation neural network, which is not fully connected.
FANN_EXTERNAL struct fann *FANN_API fann_create_sparse_array(
   float connection_rate,
   unsigned int num_layers,
   const unsigned int *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_shortcut(
   unsigned int num_layers,
    ...
)
Creates a standard backpropagation neural network, which is fully connected and which also has shortcut connections.
FANN_EXTERNAL struct fann *FANN_API fann_create_shortcut_array(
   unsigned int num_layers,
   const unsigned int *layers
)
Just like fann_create_shortcut, but with an array of layer sizes instead of individual parameters.
FANN_EXTERNAL fann_type * FANN_API fann_run(struct fann *ann,
fann_type *input)
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 void FANN_API fann_randomize_weights(struct fann *ann,
fann_type min_weight,
fann_type max_weight)
Give each connection a random weight between min_weight and max_weight
bool read_train_from_file(const std::string &filename)
Reads a file that stores training data.
FANN_EXTERNAL void FANN_API fann_init_weights(
   struct fann *ann,
   struct fann_train_data *train_data
)
Initialize the weights using Widrow + Nguyen’s algorithm.
FANN_EXTERNAL struct fann *FANN_API fann_create_from_file(
   const char *configuration_file
)
Constructs a backpropagation neural network from a configuration file, which has been saved by fann_save.
FANN_EXTERNAL int FANN_API fann_save(struct fann *ann,
const char *configuration_file)
Save 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 entire network to a configuration file.
FANN_EXTERNAL unsigned int FANN_API fann_get_num_input(struct fann *ann)
Get the number of input neurons.
FANN_EXTERNAL unsigned int FANN_API fann_get_num_output(struct fann *ann)
Get the number of output neurons.
FANN_EXTERNAL void FANN_API fann_train(struct fann *ann,
fann_type *input,
fann_type *desired_output)
Train one iteration with a set of inputs, and a set of desired outputs.
FANN_EXTERNAL void FANN_API fann_set_training_algorithm(
   struct fann *ann,
   enum fann_train_enum training_algorithm
)
Set the training algorithm.
FANN_EXTERNAL float FANN_API fann_train_epoch(struct fann *ann,
struct fann_train_data *data)
Train one epoch with a set of training data.
FANN_EXTERNAL void FANN_API fann_train_on_data(
   struct fann *ann,
   struct fann_train_data *data,
   unsigned int max_epochs,
   unsigned int epochs_between_reports,
   float desired_error
)
Trains on an entire dataset, for a period of time.
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
)
Does the same as fann_train_on_data, but reads the training data directly from a file.
FANN_EXTERNAL fann_type * FANN_API fann_test(struct fann *ann,
fann_type *input,
fann_type *desired_output)
Test with a set of inputs, and a set of desired outputs.
FANN_EXTERNAL float FANN_API fann_test_data(struct fann *ann,
struct fann_train_data *data)
Test a set of training data and calculates the MSE for the training data.
FANN_EXTERNAL float FANN_API fann_get_MSE(struct fann *ann)
Reads the mean square error from the network.
FANN_EXTERNAL void FANN_API fann_reset_MSE(struct fann *ann)
Resets the mean square error from the network.
FANN_EXTERNAL void FANN_API fann_print_parameters(struct fann *ann)
Prints all of the parameters and options of the ANN
FANN_EXTERNAL enum fann_train_enum FANN_API fann_get_training_algorithm(
   struct fann *ann
)
Return the training algorithm as described by fann_train_enum.
FANN_EXTERNAL float FANN_API fann_get_learning_rate(struct fann *ann)
Return the learning rate.
FANN_EXTERNAL enum fann_activationfunc_enum FANN_API fann_get_activation_function(
   struct fann *ann,
   int layer,
   int neuron
)
Get the activation function for neuron number neuron in layer number layer, counting the input layer as layer 0.
FANN_EXTERNAL void FANN_API fann_set_activation_function(
   struct fann *ann,
   enum fann_activationfunc_enum activation_function,
   int layer,
   int neuron
)
Set the activation function for neuron number neuron in layer number layer, counting the input layer as layer 0.
FANN_EXTERNAL void FANN_API fann_set_activation_function_layer(
   struct fann *ann,
   enum fann_activationfunc_enum activation_function,
   int layer
)
Set the activation function for all the neurons in the layer number layer, counting the input layer as layer 0.
FANN_EXTERNAL void FANN_API fann_set_activation_function_hidden(
   struct fann *ann,
   enum fann_activationfunc_enum activation_function
)
Set the activation function for all of the hidden layers.
FANN_EXTERNAL void FANN_API fann_set_activation_function_output(
   struct fann *ann,
   enum fann_activationfunc_enum activation_function
)
Set the activation function for the output layer.
FANN_EXTERNAL fann_type FANN_API fann_get_activation_steepness(
   struct fann *ann,
   int layer,
   int neuron
)
Get the activation steepness for neuron number neuron in layer number layer, counting the input layer as layer 0.
FANN_EXTERNAL void FANN_API fann_set_activation_steepness(struct fann *ann,
fann_type steepness,
int layer,
int neuron)
Set the activation steepness for neuron number neuron in layer number layer, counting the input layer as layer 0.
FANN_EXTERNAL void FANN_API fann_set_activation_steepness_layer(
   struct fann *ann,
   fann_type steepness,
   int layer
)
Set the activation steepness for all of the neurons in layer number layer, counting the input layer as layer 0.
FANN_EXTERNAL void FANN_API fann_set_activation_steepness_hidden(
   struct fann *ann,
   fann_type steepness
)
Set the steepness of the activation steepness in all of the hidden layers.
FANN_EXTERNAL void FANN_API fann_set_activation_steepness_output(
   struct fann *ann,
   fann_type steepness
)
Set the steepness of the activation steepness in the output layer.
FANN_EXTERNAL enum fann_errorfunc_enum FANN_API fann_get_train_error_function(
   struct fann *ann
)
Returns the error function used during training.
FANN_EXTERNAL void FANN_API fann_set_train_error_function(
   struct fann *ann,
   enum fann_errorfunc_enum train_error_function
)
Set the error function used during training.
FANN_EXTERNAL float FANN_API fann_get_quickprop_decay(struct fann *ann)
The decay is a small negative valued number which is the factor that the weights should become smaller in each iteration during quickprop training.
FANN_EXTERNAL void FANN_API fann_set_quickprop_decay(struct fann *ann,
float quickprop_decay)
Sets the quickprop decay factor.
FANN_EXTERNAL float FANN_API fann_get_quickprop_mu(struct fann *ann)
The mu factor is used to increase and decrease the step-size during quickprop training.
FANN_EXTERNAL void FANN_API fann_set_quickprop_mu(struct fann *ann,
float quickprop_mu)
Sets the quickprop mu factor.
FANN_EXTERNAL float FANN_API fann_get_rprop_increase_factor(struct fann *ann)
The increase factor is a value larger than 1, which is used to increase the step-size during RPROP training.
FANN_EXTERNAL void FANN_API fann_set_rprop_increase_factor(
   struct fann *ann,
   float rprop_increase_factor
)
The increase factor used during RPROP training.
FANN_EXTERNAL float FANN_API fann_get_rprop_decrease_factor(struct fann *ann)
The decrease factor is a value smaller than 1, which is used to decrease the step-size during RPROP training.
FANN_EXTERNAL void FANN_API fann_set_rprop_decrease_factor(
   struct fann *ann,
   float rprop_decrease_factor
)
The decrease factor is a value smaller than 1, which is used to decrease the step-size during RPROP training.
FANN_EXTERNAL float FANN_API fann_get_rprop_delta_zero(struct fann *ann)
The initial step-size is a positive number determining the initial step size.
FANN_EXTERNAL void FANN_API fann_set_rprop_delta_zero(struct fann *ann,
float rprop_delta_max)
The initial step-size is a positive number determining the initial step size.
FANN_EXTERNAL float FANN_API fann_get_rprop_delta_min(struct fann *ann)
The minimum step-size is a small positive number determining how small the minimum step-size may be.
FANN_EXTERNAL void FANN_API fann_set_rprop_delta_min(struct fann *ann,
float rprop_delta_min)
The minimum step-size is a small positive number determining how small the minimum step-size may be.
FANN_EXTERNAL float FANN_API fann_get_rprop_delta_max(struct fann *ann)
The maximum step-size is a positive number determining how large the maximum step-size may be.
FANN_EXTERNAL void FANN_API fann_set_rprop_delta_max(struct fann *ann,
float rprop_delta_max)
The maximum step-size is a positive number determining how large the maximum step-size may be.
FANN_EXTERNAL void FANN_API fann_set_sarprop_weight_decay_shift(
   struct fann *ann,
   float sarprop_weight_decay_shift
)
Set the sarprop weight decay shift.
FANN_EXTERNAL void FANN_API fann_set_sarprop_step_error_threshold_factor(
   struct fann *ann,
   float sarprop_step_error_threshold_factor
)
Set the sarprop step error threshold factor.
FANN_EXTERNAL void FANN_API fann_set_sarprop_step_error_shift(
   struct fann *ann,
   float sarprop_step_error_shift
)
Set the sarprop step error shift.
FANN_EXTERNAL void FANN_API fann_set_sarprop_temperature(
   struct fann *ann,
   float sarprop_temperature
)
Set the sarprop_temperature.
bool save_train_to_fixed(const std::string &filename,
unsigned int decimal_point)
Saves the training structure to a fixed point data file.
FANN_EXTERNAL unsigned int FANN_API fann_get_decimal_point(struct fann *ann)
Returns the position of the decimal point in the ann.
FANN_EXTERNAL unsigned int FANN_API fann_get_multiplier(struct fann *ann)
returns the multiplier that fix point data is multiplied with.
FANN_EXTERNAL enum fann_nettype_enum FANN_API fann_get_network_type(
   struct fann *ann
)
Get the type of neural network it was created as.
FANN_EXTERNAL float FANN_API fann_get_connection_rate(struct fann *ann)
Get the connection rate used when the network was created
FANN_EXTERNAL unsigned int FANN_API fann_get_num_layers(struct fann *ann)
Get the number of layers in the network
FANN_EXTERNAL void FANN_API fann_get_layer_array(struct fann *ann,
unsigned int *layers)
Get the number of neurons in each layer in the network.
FANN_EXTERNAL void FANN_API fann_get_bias_array(struct fann *ann,
unsigned int *bias)
Get the number of bias in each layer in the network.
FANN_EXTERNAL void FANN_API fann_get_connection_array(
   struct fann *ann,
   struct fann_connection *connections
)
Get the 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 connections 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)
Set a connection in the network.
FANN_EXTERNAL unsigned int FANN_API fann_get_bit_fail(struct fann *ann)
The number of fail bits; means the number of output neurons which differ more than the bit fail limit (see fann_get_bit_fail_limit, fann_set_bit_fail_limit).
FANN_EXTERNAL void FANN_API fann_set_train_stop_function(
   struct fann *ann,
   enum fann_stopfunc_enum train_stop_function
)
Set the stop function used during training.
FANN_EXTERNAL void FANN_API fann_cascadetrain_on_data(
   struct fann *ann,
   struct fann_train_data *data,
   unsigned int max_neurons,
   unsigned int neurons_between_reports,
   float desired_error
)
Trains on an entire dataset, for a period of time using the Cascade2 training algorithm.
FANN_EXTERNAL void FANN_API fann_cascadetrain_on_file(
   struct fann *ann,
   const char *filename,
   unsigned int max_neurons,
   unsigned int neurons_between_reports,
   float desired_error
)
Does the same as fann_cascadetrain_on_data, but reads the training data directly from a file.
FANN_EXTERNAL float FANN_API fann_get_cascade_output_change_fraction(
   struct fann *ann
)
The cascade output change fraction is a number between 0 and 1 determining how large a fraction the fann_get_MSE value should change within fann_get_cascade_output_stagnation_epochs during training of the output connections, in order for the training not to stagnate.
FANN_EXTERNAL void FANN_API fann_set_cascade_output_change_fraction(
   struct fann *ann,
   float cascade_output_change_fraction
)
Sets the cascade output change fraction.
FANN_EXTERNAL unsigned int FANN_API fann_get_cascade_output_stagnation_epochs(
   struct fann *ann
)
The number of cascade output stagnation epochs determines the number of epochs training is allowed to continue without changing the MSE by a fraction of fann_get_cascade_output_change_fraction.
FANN_EXTERNAL void FANN_API fann_set_cascade_output_stagnation_epochs(
   struct fann *ann,
   unsigned int cascade_output_stagnation_epochs
)
Sets the number of cascade output stagnation epochs.
FANN_EXTERNAL float FANN_API fann_get_cascade_candidate_change_fraction(
   struct fann *ann
)
The cascade candidate change fraction is a number between 0 and 1 determining how large a fraction the fann_get_MSE value should change within fann_get_cascade_candidate_stagnation_epochs during training of the candidate neurons, in order for the training not to stagnate.
FANN_EXTERNAL void FANN_API fann_set_cascade_candidate_change_fraction(
   struct fann *ann,
   float cascade_candidate_change_fraction
)
Sets the cascade candidate change fraction.
FANN_EXTERNAL unsigned int FANN_API fann_get_cascade_candidate_stagnation_epochs(
   struct fann *ann
)
The number of cascade candidate stagnation epochs determines the number of epochs training is allowed to continue without changing the MSE by a fraction of fann_get_cascade_candidate_change_fraction.
FANN_EXTERNAL void FANN_API fann_set_cascade_candidate_stagnation_epochs(
   struct fann *ann,
   unsigned int cascade_candidate_stagnation_epochs
)
Sets the number of cascade candidate stagnation epochs.
FANN_EXTERNAL fann_type FANN_API fann_get_cascade_weight_multiplier(
   struct fann *ann
)
The weight multiplier is a parameter which is used to multiply the weights from the candidate neuron before adding the neuron to the neural network.
FANN_EXTERNAL void FANN_API fann_set_cascade_weight_multiplier(
   struct fann *ann,
   fann_type cascade_weight_multiplier
)
Sets the weight multiplier.
FANN_EXTERNAL fann_type FANN_API fann_get_cascade_candidate_limit(
   struct fann *ann
)
The candidate limit is a limit for how much the candidate neuron may be trained.
FANN_EXTERNAL void FANN_API fann_set_cascade_candidate_limit(
   struct fann *ann,
   fann_type cascade_candidate_limit
)
Sets the candidate limit.
FANN_EXTERNAL unsigned int FANN_API fann_get_cascade_max_out_epochs(
   struct fann *ann
)
The maximum out epochs determines the maximum number of epochs the output connections may be trained after adding a new candidate neuron.
FANN_EXTERNAL void FANN_API fann_set_cascade_max_out_epochs(
   struct fann *ann,
   unsigned int cascade_max_out_epochs
)
Sets the maximum out epochs.
FANN_EXTERNAL unsigned int FANN_API fann_get_cascade_max_cand_epochs(
   struct fann *ann
)
The maximum candidate epochs determines the maximum number of epochs the input connections to the candidates may be trained before adding a new candidate neuron.
FANN_EXTERNAL void FANN_API fann_set_cascade_max_cand_epochs(
   struct fann *ann,
   unsigned int cascade_max_cand_epochs
)
Sets the max candidate epochs.
FANN_EXTERNAL unsigned int FANN_API fann_get_cascade_num_candidates(
   struct fann *ann
)
The number of candidates used during training (calculated by multiplying fann_get_cascade_activation_functions_count, fann_get_cascade_activation_steepnesses_count and fann_get_cascade_num_candidate_groups).
FANN_EXTERNAL unsigned int FANN_API fann_get_cascade_activation_functions_count(
   struct fann *ann
)
The number of activation functions in the fann_get_cascade_activation_functions array.
FANN_EXTERNAL void FANN_API fann_set_cascade_activation_functions(
   struct fann *ann,
   enum fann_activationfunc_enum *cascade_activation_functions,
   unsigned int cascade_activation_functions_count
)
Sets the array of cascade candidate activation functions.
FANN_EXTERNAL unsigned int FANN_API fann_get_cascade_activation_steepnesses_count(
   struct fann *ann
)
The number of activation steepnesses in the fann_get_cascade_activation_functions array.
FANN_EXTERNAL fann_type * FANN_API fann_get_cascade_activation_steepnesses(
   struct fann *ann
)
The cascade activation steepnesses array is an array of the different activation functions used by the candidates.
FANN_EXTERNAL void FANN_API fann_set_cascade_activation_steepnesses(
   struct fann *ann,
   fann_type *cascade_activation_steepnesses,
   unsigned int cascade_activation_steepnesses_count
)
Sets the array of cascade candidate activation steepnesses.
FANN_EXTERNAL unsigned int FANN_API fann_get_cascade_num_candidate_groups(
   struct fann *ann
)
The number of candidate groups is the number of groups of identical candidates which will be used during training.
FANN_EXTERNAL void FANN_API fann_set_cascade_num_candidate_groups(
   struct fann *ann,
   unsigned int cascade_num_candidate_groups
)
Sets the number of candidate groups.
FANN_EXTERNAL void FANN_API fann_scale_train(struct fann *ann,
struct fann_train_data *data)
Scale input and output data based on previously calculated parameters.
FANN_EXTERNAL void FANN_API fann_descale_train(struct fann *ann,
struct fann_train_data *data)
Descale input and output data based on previously calculated parameters.
FANN_EXTERNAL int FANN_API fann_set_input_scaling_params(
   struct fann *ann,
   const struct fann_train_data *data,
   float new_input_min,
   float new_input_max
)
Calculate input scaling parameters for future use based on training data.
FANN_EXTERNAL int FANN_API fann_set_output_scaling_params(
   struct fann *ann,
   const struct fann_train_data *data,
   float new_output_min,
   float new_output_max
)
Calculate output scaling parameters for future use based on training data.
FANN_EXTERNAL int FANN_API fann_set_scaling_params(
   struct fann *ann,
   const struct fann_train_data *data,
   float new_input_min,
   float new_input_max,
   float new_output_min,
   float new_output_max
)
Calculate input and output scaling parameters for future use based on training data.
FANN_EXTERNAL int FANN_API fann_clear_scaling_params(struct fann *ann)
Clears scaling parameters.
FANN_EXTERNAL void FANN_API fann_scale_input(struct fann *ann,
fann_type *input_vector)
Scale data in input vector before feeding it to ann based on previously calculated parameters.
FANN_EXTERNAL void FANN_API fann_scale_output(struct fann *ann,
fann_type *output_vector)
Scale data in output vector before feeding it to ann based on previously calculated parameters.
FANN_EXTERNAL void FANN_API fann_descale_input(struct fann *ann,
fann_type *input_vector)
Scale data in input vector after getting it from ann based on previously calculated parameters.
FANN_EXTERNAL void FANN_API fann_descale_output(struct fann *ann,
fann_type *output_vector)
Scale data in output vector after getting it from ann based on previously calculated parameters.
struct fann_error
Structure used to store error-related information, both struct fann and struct fann_train_data can be casted to this type.
FANN_EXTERNAL void FANN_API fann_set_error_log(struct fann_error *errdat,
FILE *log_file)
Change where errors are logged to.
Used to define error events on struct fann and struct fann_train_data.
FANN_EXTERNAL void FANN_API fann_reset_errno(struct fann_error *errdat)
Resets the last error number.
FANN_EXTERNAL enum fann_errno_enum FANN_API fann_get_errno(
   struct fann_error *errdat
)
Returns the last error number.
FANN_EXTERNAL void FANN_API fann_reset_errstr(struct fann_error *errdat)
Resets the last error string.
Close