The Fann Wrapper for C# provides Six main classes: FANNCSharp.Float::NeuralNet, FANNCSharp.Double::NeuralNet, FANNCSharp.Fixed::NeuralNet, FANNCSharp.Float::TrainingData, FANNCSharp.Double::TrainingData, FANNCSharp.Fixed::TrainingData. To use the wrapper add FANNCSharp.dll, FANNCSharp.Float.dll, FANNCSharp.Double.dll, FANNCSharp.Fixed.dll as a reference to your project.
To get started see XorSample project. The license is LGPL. Copyright © 2015 created by joel@gmai l.com. self
Note: Notes and differences from C++ API
FANN C# NeuralNet Fixed | The Fann Wrapper for C# provides Six main classes: FANNCSharp.Float::NeuralNet, FANNCSharp.Double::NeuralNet, FANNCSharp.Fixed::NeuralNet, FANNCSharp.Float::TrainingData, FANNCSharp.Double::TrainingData, FANNCSharp.Fixed::TrainingData. |
NeuralNet | NeuralNet is the main neural network class used for both training and execution using ints |
Functions and Properties | |
NeuralNet | Creates a copy the other NeuralNet. |
Dispose | Destructs the entire network. |
NeuralNet | Creates a neural network of the desired NetworkType net_type. |
NeuralNet | Creates a neural network of the desired NetworkType netType, based on a collection of layers. |
NeuralNet | Creates a standard backpropagation neural network, which is sparsely connected, this will default the NetworkType to NetworkType::LAYER |
NeuralNet | Creates a standard backpropagation neural network, which is sparsely connected, this will default the NetworkType to NetworkType::LAYER |
NeuralNet | Constructs a backpropagation neural network from a configuration file, which have been saved by Save. |
Run | 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. |
Run | 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. |
RandomizeWeights | Give each connection a random weight between minWeight and maxWeight |
InitWeights | Initialize the weights using Widrow + Nguyen’s algorithm. |
PrintConnections | Will print the connections of the network in a compact matrix, for easy viewing of the internals of the network. |
Save | Save the entire network to a configuration file. |
SaveToFixed | Saves the entire network to a configuration file. |
Test | Test with a set of inputs, and a set of desired outputs. |
TestData | Test a set of training data and calculates the MSE for the training data. |
MSE | Reads the mean square error from the network. |
ResetMSE | Resets the mean square error from the network. |
PrintParameters | Prints all of the parameters and options of the neural network |
TrainingAlgorithm | Return or set the training algorithm as described by TrainingAlgorithm. |
LearningRate | Return or set the learning rate. |
GetActivationFunction | Get the activation function for neuron number neuron in layer number layer, counting the input layer as layer 0. |
SetActivationFunction | Set the activation function for neuron number neuron in layer number layer, counting the input layer as layer 0. |
SetActivationFunctionLayer | Set the activation function for all the neurons in the layer number layer, counting the input layer as layer 0. |
ActivationFunctionHidden | Set the activation function for all of the hidden layers. |
ActivationFunctionOutput | Set the activation function for the output layer. |
GetActivationSteepness | Get the activation steepness for neuron number neuron in layer number layer, counting the input layer as layer 0. |
SetActivationSteepness | Set the activation steepness for neuron number neuron in layer number layer, counting the input layer as layer 0. |
SetActivationSteepnessLayer | Set the activation steepness all of the neurons in layer number layer, counting the input layer as layer 0. |
ActivationSteepnessHidden | Set the steepness of the activation steepness in all of the hidden layers. |
ActivationSteepnessOutput | Set the steepness of the activation steepness in the output layer. |
TrainErrorFunction | Sets or returns the error function used during training. |
QuickpropDecay | Gets or sets the quickprop decay factor. |
QuickpropMu | Get or sets the quickprop mu factor. |
RpropIncreaseFactor | Gets or sets the increase factor used during RPROP training. |
RpropDecreaseFactor | Gets or sets the rprop decrease factor. |
RpropDeltaZero | Gets or sets the rprop delta zero. |
RpropDeltaMin | Gets or sets the rprop delta min. |
RpropDeltaMax | Gets or set the rprop delta max. |
SarpropWeightDecayShift | Gets or sets the sarprop weight decay shift. |
SarpropStepErrorThresholdFactor | Gets or sets the sarprop step error threshold factor. |
SarpropStepErrorShift | Gets or sets the sarprop step error shift. |
SarpropTemperature | Gets or set the sarprop weight decay shift. |
InputCount | Get the number of input neurons. |
OutputCount | Get the number of output neurons. |
TotalNeurons | Get the total number of neurons in the entire network. |
TotalConnections | Get the total number of connections in the entire network. |
DecimalPoint | Returns the position of the decimal point in the ann. |
Multiplier | Returns the multiplier that fix point data is multiplied with. |
NetworkType | Get the type of neural network it was created as. |
ConnectionRate | Get the connection rate used when the network was created |
LayerCount | Get the number of layers in the network |
Layers | Get the number of neurons in each layer in the network. |
Biases | Get the number of bias in each layer in the network. |
Connections | Get the connections in the network. |
Weights | Set connections in the network. |
SetWeight | Set a connection in the network. |
LearningMomentum | Get or set the learning momentum. |
TrainStopFunction | Gets or sets the stop function used during training. |
BitFailLimit | Gets or sets the bit fail limit used during training. |
BitFail | Gets or set the number of fail bits. |
ErrorLog | Change where errors are logged to. |
ErrNo | Returns the last error number. |
ResetErrno | Resets the last error number. |
ResetErrstr | Resets the last error string. |
ErrStr | Returns the last errstr. |
PrintError | Prints the last error to Console.Error. |
DisableSeedRand | Disables the automatic random generator seeding that happens in FANN. |
EnableSeedRand | Enables the automatic random generator seeding that happens in FANN. |
IDisposable |
FANNCSharp.Fixed.NeuralNet |
NeuralNet is the main neural network class used for both training and execution using ints
Encapsulation of a int neural network neural_net and associated C++ API functions.
Functions and Properties | |
NeuralNet | Creates a copy the other NeuralNet. |
Dispose | Destructs the entire network. |
NeuralNet | Creates a neural network of the desired NetworkType net_type. |
NeuralNet | Creates a neural network of the desired NetworkType netType, based on a collection of layers. |
NeuralNet | Creates a standard backpropagation neural network, which is sparsely connected, this will default the NetworkType to NetworkType::LAYER |
NeuralNet | Creates a standard backpropagation neural network, which is sparsely connected, this will default the NetworkType to NetworkType::LAYER |
NeuralNet | Constructs a backpropagation neural network from a configuration file, which have been saved by Save. |
Run | 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. |
Run | 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. |
RandomizeWeights | Give each connection a random weight between minWeight and maxWeight |
InitWeights | Initialize the weights using Widrow + Nguyen’s algorithm. |
PrintConnections | Will print the connections of the network in a compact matrix, for easy viewing of the internals of the network. |
Save | Save the entire network to a configuration file. |
SaveToFixed | Saves the entire network to a configuration file. |
Test | Test with a set of inputs, and a set of desired outputs. |
TestData | Test a set of training data and calculates the MSE for the training data. |
MSE | Reads the mean square error from the network. |
ResetMSE | Resets the mean square error from the network. |
PrintParameters | Prints all of the parameters and options of the neural network |
TrainingAlgorithm | Return or set the training algorithm as described by TrainingAlgorithm. |
LearningRate | Return or set the learning rate. |
GetActivationFunction | Get the activation function for neuron number neuron in layer number layer, counting the input layer as layer 0. |
SetActivationFunction | Set the activation function for neuron number neuron in layer number layer, counting the input layer as layer 0. |
SetActivationFunctionLayer | Set the activation function for all the neurons in the layer number layer, counting the input layer as layer 0. |
ActivationFunctionHidden | Set the activation function for all of the hidden layers. |
ActivationFunctionOutput | Set the activation function for the output layer. |
GetActivationSteepness | Get the activation steepness for neuron number neuron in layer number layer, counting the input layer as layer 0. |
SetActivationSteepness | Set the activation steepness for neuron number neuron in layer number layer, counting the input layer as layer 0. |
SetActivationSteepnessLayer | Set the activation steepness all of the neurons in layer number layer, counting the input layer as layer 0. |
ActivationSteepnessHidden | Set the steepness of the activation steepness in all of the hidden layers. |
ActivationSteepnessOutput | Set the steepness of the activation steepness in the output layer. |
TrainErrorFunction | Sets or returns the error function used during training. |
QuickpropDecay | Gets or sets the quickprop decay factor. |
QuickpropMu | Get or sets the quickprop mu factor. |
RpropIncreaseFactor | Gets or sets the increase factor used during RPROP training. |
RpropDecreaseFactor | Gets or sets the rprop decrease factor. |
RpropDeltaZero | Gets or sets the rprop delta zero. |
RpropDeltaMin | Gets or sets the rprop delta min. |
RpropDeltaMax | Gets or set the rprop delta max. |
SarpropWeightDecayShift | Gets or sets the sarprop weight decay shift. |
SarpropStepErrorThresholdFactor | Gets or sets the sarprop step error threshold factor. |
SarpropStepErrorShift | Gets or sets the sarprop step error shift. |
SarpropTemperature | Gets or set the sarprop weight decay shift. |
InputCount | Get the number of input neurons. |
OutputCount | Get the number of output neurons. |
TotalNeurons | Get the total number of neurons in the entire network. |
TotalConnections | Get the total number of connections in the entire network. |
DecimalPoint | Returns the position of the decimal point in the ann. |
Multiplier | Returns the multiplier that fix point data is multiplied with. |
NetworkType | Get the type of neural network it was created as. |
ConnectionRate | Get the connection rate used when the network was created |
LayerCount | Get the number of layers in the network |
Layers | Get the number of neurons in each layer in the network. |
Biases | Get the number of bias in each layer in the network. |
Connections | Get the connections in the network. |
Weights | Set connections in the network. |
SetWeight | Set a connection in the network. |
LearningMomentum | Get or set the learning momentum. |
TrainStopFunction | Gets or sets the stop function used during training. |
BitFailLimit | Gets or sets the bit fail limit used during training. |
BitFail | Gets or set the number of fail bits. |
ErrorLog | Change where errors are logged to. |
ErrNo | Returns the last error number. |
ResetErrno | Resets the last error number. |
ResetErrstr | Resets the last error string. |
ErrStr | Returns the last errstr. |
PrintError | Prints the last error to Console.Error. |
DisableSeedRand | Disables the automatic random generator seeding that happens in FANN. |
EnableSeedRand | Enables the automatic random generator seeding that happens in FANN. |
public NeuralNet( NetworkType netType, uint numLayers, params uint[] args )
Creates a neural network of the desired NetworkType net_type.
numLayers | The 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. |
unt numLayes = 3; uint numInput = 2; uint numHidden = 3; uint numOutput = 1; NeuralNet net(numLayers, numInput, numHidden, numOutput);
This function appears in FANN >= 2.3.0.
public NeuralNet( NetworkType netType, ICollection<uint> layers )
Creates a neural network of the desired NetworkType netType, based on a collection of layers.
netType | The desired network type of the neural network |
layers | the collection of layer sizes |
NeuralNet net(NetworkType.LAYER, new uint[] {2, 3, 1});
This function appears in FANN >= 2.3.0.
public NeuralNet( float connectionRate, uint numLayers, params uint[] args )
Creates a standard backpropagation neural network, which is sparsely connected, this will default the NetworkType to NetworkType::LAYER
connectionRate | The 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 |
numLayers | The 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.
public NeuralNet( float connectionRate, ICollection<uint> layers )
Creates a standard backpropagation neural network, which is sparsely connected, this will default the NetworkType to NetworkType::LAYER
connectionRate | The 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 |
numLayers | The total number of layers including the input and the output layer. |
layers | 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.
public NeuralNet( string filename )
Constructs a backpropagation neural network from a configuration file, which have been saved by Save.
This function appears in FANN >= 2.3.0.
public int[] Run( DataAccessor 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.
input | A DataAccessor that points to the inputs to run through the neural network |
This function appears in FANN >= 1.0.0.
public void RandomizeWeights( int minWeight, int maxWeight )
Give each connection a random weight between minWeight and maxWeight
From the beginning the weights are random between -0.1 and 0.1.
InitWeights, fann_randomize_weights
This function appears in FANN >= 1.0.0.
public void InitWeights( TrainingData 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.
RandomizeWeights, TrainingData::ReadTrainFromFile, fann_init_weights
This function appears in FANN >= 1.1.0.
public void PrintConnections()
Will print the connections of the network in a compact matrix, for easy viewing of the internals of the network.
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.
public bool Save( string file )
Save the entire network to a configuration file.
The configuration file contains all information about the neural network and enables <NeuralNet(string filename)> to create an exact copy of the neural network and all of the parameters associated with the neural network.
These two parameters (<SetCallback>, ErrorLog) are NOT saved to the file because they cannot safely be ported to a different location. Also temporary parameters generated during training like MSE is not saved.
The function returns true on success and false on failure.
NeuralNet, SaveToFixed, fann_save
This function appears in FANN >= 1.0.0.
public int SaveToFixed( string 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.
NeuralNet, Save, fann_save_to_fixed
This function appears in FANN >= 1.0.0.
public float TestData( TrainingData 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.
Test, MSE, BitFail, fann_test_data
This function appears in FANN >= 1.2.0.
public float MSE { get }
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.
This function appears in FANN >= 1.1.0.
public void ResetMSE()
Resets the mean square error from the network.
This function also resets the number of bits that fail.
MSE, BitFailLimit, fann_reset_MSE
This function appears in FANN >= 1.1.0
public TrainingAlgorithm TrainingAlgorithm { get, set }
Return or set the training algorithm as described by TrainingAlgorithm. This training algorithm is used by <TrainOnData> and associated functions.
Note that this algorithm is also used during <CascadetrainOnData>, although only TrainingAlgorithm.TRAIN_RPROP and TrainingAlgorithm.:TRAIN_QUICKPROP is allowed during cascade training.
The default training algorithm is TrainingAlgorithm.TRAIN_RPROP.
TrainingAlgorithm, fann_get_training_algorithm, fann_set_training_algorithm
This function appears in FANN >= 1.0.0.
public float LearningRate { get, set }
Return or set the learning rate.
The learning rate is used to determine how aggressive training should be for some of the training algorithms (TrainingAlgorithm.TRAIN_INCREMENTAL, TrainingAlgorithm.TRAIN_BATCH, TrainingAlgorithm.TRAIN_QUICKPROP). Do however note that it is not used in TrainingAlgorithm.TRAIN_RPROP.
The default learning rate is 0.7.
TrainingAlgorithm, fann_get_learning_rate, fann_set_learning_rate
This function appears in FANN >= 1.0.0.
public ActivationFunction GetActivationFunction( 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 ActivationFunction.
The activation function for the neuron or -1 if the neuron is not defined in the neural network.
SetActivationFunctionLayer, ActivationFunctionHidden, ActivationFunctionOutput, SetActivationSteepness, SetActivationFunction, fann_get_activation_function
This function appears in FANN >= 2.1.0
public void SetActivationFunction( ActivationFunction 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 ActivationFunction.
The default activation function is FANN::SIGMOID_STEPWISE.
SetActivationFunctionLayer, ActivationFunctionHidden, ActivationFunctionOutput, SetActivationSteepness, GetActivationFunction, fann_get_activation_function
This function appears in FANN >= 2.0.0.
public void SetActivationFunctionLayer( ActivationFunction 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.
SetActivationFunction, ActivationFunctionHidden, ActivationFunctionOutput, SetActivationSteepnessLayer, fann_set_activation_function_layer
This function appears in FANN >= 2.0.0.
public ActivationFunction ActivationFunctionHidden { set }
Set the activation function for all of the hidden layers.
SetActivationFunction, SetActivationFunctionLayer, ActivationFunctionOutput, ActivationSteepnessHidden, fann_set_activation_function_hidden
This function appears in FANN >= 1.0.0.
public ActivationFunction ActivationFunctionOutput { set }
Set the activation function for the output layer.
SetActivationFunction, SetActivationFunctionLayer, ActivationFunctionHidden, ActivationSteepnessOutput, fann_set_activation_function_output
This function appears in FANN >= 1.0.0.
public int GetActivationSteepness( 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.
The activation steepness for the neuron or -1 if the neuron is not defined in the neural network.
SetActivationSteepnessLayer, ActivationSteepnessHidden, ActivationSteepnessOutput, SetActivationFunction, SetActivationSteepness, fann_get_activation_steepness
This function appears in FANN >= 2.1.0
public void SetActivationSteepness( int 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.
SetActivationSteepnessLayer, ActivationSteepnessHidden, ActivationSteepnessOutput, SetActivationFunction, GetActivationSteepness, fann_set_activation_steepness
This function appears in FANN >= 2.0.0.
public void SetActivationSteepnessLayer( int 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.
SetActivationSteepness, ActivationSteepnessHidden, ActivationSteepnessOutput, SetActivationFunctionLayer, fann_set_activation_steepness_layer
This function appears in FANN >= 2.0.0.
public int ActivationSteepnessHidden { set }
Set the steepness of the activation steepness in all of the hidden layers.
SetActivationSteepness, SetActivationSteepnessLayer, ActivationSteepnessOutput, ActivationFunctionHidden, fann_set_activation_steepness_hidden
This function appears in FANN >= 1.2.0.
public int ActivationSteepnessOutput { set }
Set the steepness of the activation steepness in the output layer.
SetActivationSteepness, SetActivationSteepnessLayer, ActivationFunctionHidden, ActivationSteepnessOutput, fann_set_activation_steepness_output
This function appears in FANN >= 1.2.0.
public ErrorFunction TrainErrorFunction { get, set }
Sets or returns the error function used during training.
The error functions is described further in ErrorFunction
The default error function is ErrorFunction.ERRORFUNC_TANH
fann_get_train_error_function, fann_set_train_error_function
This function appears in FANN >= 1.2.0.
public float QuickpropDecay { get, set }
Gets or sets the quickprop decay factor.
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.
fann_get_quickprop_decay, fann_set_quickprop_decay
This function appears in FANN >= 1.2.0.
public float QuickpropMu { get, set }
Get or sets the quickprop mu factor.
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.
fann_get_quickprop_mu, fann_set_quickprop_mu
This function appears in FANN >= 1.2.0.
public float RpropIncreaseFactor { get, set }
Gets or sets the increase factor used during RPROP training.
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.
fann_get_rprop_increase_factor, fann_set_rprop_increase_factor
This function appears in FANN >= 1.2.0.
public float RpropDecreaseFactor { get, set }
Gets or sets the 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.
fann_get_rprop_decrease_factor, fann_set_rprop_decrease_factor
This function appears in FANN >= 1.2.0.
public float RpropDeltaZero { get, set }
Gets or sets the 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.
fann_get_rprop_delta_zero, fann_set_rprop_delta_zero
This function appears in FANN >= 2.1.0.
public float RpropDeltaMin { get, set }
Gets or sets the 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.
fann_get_rprop_delta_min, fann_set_rprop_delta_min
This function appears in FANN >= 1.2.0.
public float RpropDeltaMax { get, set }
Gets or set the 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.
RpropDeltaMin, fann_get_rprop_delta_max, fann_set_rprop_delta_max
This function appears in FANN >= 1.2.0.
public float SarpropWeightDecayShift { get, set }
Gets or sets the sarprop weight decay shift.
The default delta max is -6.644.
fann_get_sarprop_weight_decay_shift, fann_set_sarprop_weight_decay_shift
This function appears in FANN >= 2.1.0.
public float SarpropStepErrorThresholdFactor { get, set }
Gets or sets the sarprop step error threshold factor.
The default delta max is 0.1.
fann_get_sarprop_step_error_threshold_factor, fann_set_sarprop_step_error_threshold_factor
This function appears in FANN >= 2.1.0.
public float SarpropStepErrorShift { get, set }
Gets or sets the sarprop step error shift.
The default delta max is 1.385.
fann_get_sarprop_step_error_shift, fann_set_sarprop_step_error_shift
This function appears in FANN >= 2.1.0.
public float SarpropTemperature { get, set }
Gets or set the sarprop weight decay shift.
The default delta max is 0.015.
fann_get_sarprop_temperature, fann_set_sarprop_temperature
This function appears in FANN >= 2.1.0.
public uint DecimalPoint { get }
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>.
Fixed Point Usage, Multiplier, SaveToFixed, TrainingData::SaveTrainToFixed, fann_get_decimal_point
This function appears in FANN >= 1.0.0.
public uint Multiplier { get }
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>.
Fixed Point Usage, DecimalPoint, SaveToFixed, TrainingData::SaveTrainToFixed, fann_get_multiplier
This function appears in FANN >= 1.0.0.
public NetworkType NetworkType { get }
Get the type of neural network it was created as.
The neural network type from enum NetworkType
This function appears in FANN >= 2.1.0
public float LearningMomentum { get, set }
Get or set the learning momentum.
The learning momentum can be used to speed up TrainingAlgorithm.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.
This function appears in FANN >= 2.0.0.
public StopFunction TrainStopFunction { get, set }
Gets or sets the stop function used during training.
The stop function is described further in StopFunction
The default stop function is StopFunction.STOPFUNC_MSE
This function appears in FANN >= 2.0.0.
public int BitFailLimit { get, set }
Gets or sets the bit fail limit used during training.
The bit fail limit is used during training when the StopFunction is set to StopFunction.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.
This function appears in FANN >= 2.0.0.
public uint BitFail { get }
Gets or set the number of fail bits. Means the number of output neurons which differ more than the bit fail limit (see BitFailLimit). 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 ResetMSE and updated by all the same functions which also updates the MSE value (e.g. TestData, <TrainEpoch>)
This function appears in FANN >= 2.0.0
public FannFile ErrorLog { set }
Change where errors are logged to.
If the value is NULL, no errors will be printed.
If NeuralNet is empty the default log will be set. The default log is the log used when creating a NeuralNet. This default log will also be the default for all new NeuralNet that are created.
The default behavior is to log them to Console.Error.
struct fann_error, fann_set_error_log
This function appears in FANN >= 1.1.0.
public uint ErrNo { get }
Returns the last error number.
fann_errno_enum, fann_reset_errno, fann_get_errno
This function appears in FANN >= 1.1.0.
public string ErrStr { get }
Returns the last errstr.
This function calls fann_reset_errno and fann_reset_errstr
This function appears in FANN >= 1.1.0.
public void DisableSeedRand()
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
public void EnableSeedRand()
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
Creates a copy the other NeuralNet.
public NeuralNet( NeuralNet other )
Destructs the entire network.
public void Dispose()
Get the type of neural network it was created as.
public NetworkType NetworkType { get }
Save the entire network to a configuration file.
public bool Save( string file )
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.
public int[] Run( int[] input )
Give each connection a random weight between minWeight and maxWeight
public void RandomizeWeights( int minWeight, int maxWeight )
Initialize the weights using Widrow + Nguyen’s algorithm.
public void InitWeights( TrainingData data )
Will print the connections of the network in a compact matrix, for easy viewing of the internals of the network.
public void PrintConnections()
Saves the entire network to a configuration file.
public int SaveToFixed( string file )
Test with a set of inputs, and a set of desired outputs.
public int[] Test( int[] input, int[] desiredOutput )
Test a set of training data and calculates the MSE for the training data.
public float TestData( TrainingData data )
Reads the mean square error from the network.
public float MSE { get }
Resets the mean square error from the network.
public void ResetMSE()
Prints all of the parameters and options of the neural network
public void PrintParameters()
Return or set the training algorithm as described by TrainingAlgorithm.
public TrainingAlgorithm TrainingAlgorithm { get, set }
Return or set the learning rate.
public float LearningRate { get, set }
Get the activation function for neuron number neuron in layer number layer, counting the input layer as layer 0.
public ActivationFunction GetActivationFunction( int layer, int neuron )
Set the activation function for neuron number neuron in layer number layer, counting the input layer as layer 0.
public void SetActivationFunction( ActivationFunction function, int layer, int neuron )
Set the activation function for all the neurons in the layer number layer, counting the input layer as layer 0.
public void SetActivationFunctionLayer( ActivationFunction function, int layer )
Set the activation function for all of the hidden layers.
public ActivationFunction ActivationFunctionHidden { set }
Set the activation function for the output layer.
public ActivationFunction ActivationFunctionOutput { set }
Get the activation steepness for neuron number neuron in layer number layer, counting the input layer as layer 0.
public int GetActivationSteepness( int layer, int neuron )
Set the activation steepness for neuron number neuron in layer number layer, counting the input layer as layer 0.
public void SetActivationSteepness( int steepness, int layer, int neuron )
Set the activation steepness all of the neurons in layer number layer, counting the input layer as layer 0.
public void SetActivationSteepnessLayer( int steepness, int layer )
Set the steepness of the activation steepness in all of the hidden layers.
public int ActivationSteepnessHidden { set }
Set the steepness of the activation steepness in the output layer.
public int ActivationSteepnessOutput { set }
Sets or returns the error function used during training.
public ErrorFunction TrainErrorFunction { get, set }
Gets or sets the quickprop decay factor.
public float QuickpropDecay { get, set }
Get or sets the quickprop mu factor.
public float QuickpropMu { get, set }
Gets or sets the increase factor used during RPROP training.
public float RpropIncreaseFactor { get, set }
Gets or sets the rprop decrease factor.
public float RpropDecreaseFactor { get, set }
Gets or sets the rprop delta zero.
public float RpropDeltaZero { get, set }
Gets or sets the rprop delta min.
public float RpropDeltaMin { get, set }
Gets or set the rprop delta max.
public float RpropDeltaMax { get, set }
Gets or sets the sarprop weight decay shift.
public float SarpropWeightDecayShift { get, set }
Gets or sets the sarprop step error threshold factor.
public float SarpropStepErrorThresholdFactor { get, set }
Gets or sets the sarprop step error shift.
public float SarpropStepErrorShift { get, set }
Gets or set the sarprop weight decay shift.
public float SarpropTemperature { get, set }
Get the number of input neurons.
public uint InputCount { get }
Get the number of output neurons.
public uint OutputCount { get }
Get the total number of neurons in the entire network.
public uint TotalNeurons { get }
Get the total number of connections in the entire network.
public uint TotalConnections { get }
Returns the position of the decimal point in the ann.
public uint DecimalPoint { get }
Returns the multiplier that fix point data is multiplied with.
public uint Multiplier { get }
Get the connection rate used when the network was created
public float ConnectionRate { get }
Get the number of layers in the network
public uint LayerCount { get }
Get the number of neurons in each layer in the network.
public uint[] Layers { get }
Get the number of bias in each layer in the network.
public uint[] Biases { get }
Get the connections in the network.
public Connection[] Connections { get }
Set connections in the network.
public Connection[] Weights { set }
Set a connection in the network.
public void SetWeight( uint fromNeuron, uint toNeuron, int weight )
Get or set the learning momentum.
public float LearningMomentum { get, set }
Gets or sets the stop function used during training.
public StopFunction TrainStopFunction { get, set }
Gets or sets the bit fail limit used during training.
public int BitFailLimit { get, set }
Gets or set the number of fail bits.
public uint BitFail { get }
Change where errors are logged to.
public FannFile ErrorLog { set }
Returns the last error number.
public uint ErrNo { get }
Resets the last error number.
public void ResetErrno()
Resets the last error string.
public void ResetErrstr()
Returns the last errstr.
public string ErrStr { get }
Prints the last error to Console.Error.
public void PrintError()
Disables the automatic random generator seeding that happens in FANN.
public void DisableSeedRand()
Enables the automatic random generator seeding that happens in FANN.
public void EnableSeedRand()
Reads a file that stores training data.
public bool ReadTrainFromFile( string filename )
Saves the training structure to a fixed point data file.
public bool SaveTrainToFixed( string filename, uint decimalPoint )