FANN C# TrainingData Double

Summary
FANN C# TrainingData Double
TrainingDataTrainingData is used to create and manipulate training data used by the NeuralNet
Functions
TrainingDataDefault constructor creates an empty training data.
TrainingDataReads a file that stores training data.
TrainingDataCopy constructor constructs a copy of the training data.
DisposeDisposes of the training data.
ReadTrainFromFileReads a file that stores training data.
SaveTrainSave the training structure to a file, with the format as specified in ReadTrainFromFile
SaveTrainToFixedSaves the training structure to a fixed point data file.
ShuffleTrainDataShuffles training data, randomizing the order.
MergeTrainDataMerges the data into the data contained in the TrainingData.
Properties
TrainDataLengthReturns the number of training patterns in the TrainingData.
InputCountReturns the number of inputs in each of the training patterns in the TrainingData.
OutputCountReturns the number of outputs in each of the training patterns in the TrainingData.
InputGrant access to the encapsulated data since many situations and applications creates the data from sources other than files or uses the training data for testing and related functions.
InputAccessorAn alternative to Input that returns an accessor object that grants access to to the input data with no copying.
OutputGrant access to the encapsulated data since many situations and applications creates the data from sources other than files or uses the training data for testing and related functions.
OutputAccessorAn alternative to Output that returns an accessor object that grants access to to the input data with no copying.
Functions
GetTrainInputGets the training input data at the given position
GetTrainOutputGets the training output data at the given position
SetTrainDataSet the training data to the input and output data provided.
SetTrainDataSet the training data to the input and output data provided.
CreateTrainFromCallbackCreates the training data from a user supplied function.
Properties
MinInputGet the minimum value of all in the input data
MaxInputGet the maximum value of all in the input data
MinOutputGet the minimum value of all in the output data
MaxOutputGet the maximum value of all in the output data
Functions
ScaleInputTrainDataScales the inputs in the training data to the specified range.
ScaleOutputTrainDataScales the outputs in the training data to the specified range.
ScaleTrainDataScales the inputs and outputs in the training data to the specified range.
SubsetTrainDataChanges the training data to a subset, starting at position pos and length elements forward.
Delegates
DataCreateCallbackCalled for each trianing data input/output pair to create the entire training data set.

TrainingData

IDisposable
FANNCSharp.Double.TrainingData

TrainingData is used to create and manipulate training data used by the NeuralNet

Encapsulation of a training_data class training_data and associated C++ API functions.

Summary
Functions
TrainingDataDefault constructor creates an empty training data.
TrainingDataReads a file that stores training data.
TrainingDataCopy constructor constructs a copy of the training data.
DisposeDisposes of the training data.
ReadTrainFromFileReads a file that stores training data.
SaveTrainSave the training structure to a file, with the format as specified in ReadTrainFromFile
SaveTrainToFixedSaves the training structure to a fixed point data file.
ShuffleTrainDataShuffles training data, randomizing the order.
MergeTrainDataMerges the data into the data contained in the TrainingData.
Properties
TrainDataLengthReturns the number of training patterns in the TrainingData.
InputCountReturns the number of inputs in each of the training patterns in the TrainingData.
OutputCountReturns the number of outputs in each of the training patterns in the TrainingData.
InputGrant access to the encapsulated data since many situations and applications creates the data from sources other than files or uses the training data for testing and related functions.
InputAccessorAn alternative to Input that returns an accessor object that grants access to to the input data with no copying.
OutputGrant access to the encapsulated data since many situations and applications creates the data from sources other than files or uses the training data for testing and related functions.
OutputAccessorAn alternative to Output that returns an accessor object that grants access to to the input data with no copying.
Functions
GetTrainInputGets the training input data at the given position
GetTrainOutputGets the training output data at the given position
SetTrainDataSet the training data to the input and output data provided.
SetTrainDataSet the training data to the input and output data provided.
CreateTrainFromCallbackCreates the training data from a user supplied function.
Properties
MinInputGet the minimum value of all in the input data
MaxInputGet the maximum value of all in the input data
MinOutputGet the minimum value of all in the output data
MaxOutputGet the maximum value of all in the output data
Functions
ScaleInputTrainDataScales the inputs in the training data to the specified range.
ScaleOutputTrainDataScales the outputs in the training data to the specified range.
ScaleTrainDataScales the inputs and outputs in the training data to the specified range.
SubsetTrainDataChanges the training data to a subset, starting at position pos and length elements forward.
Delegates
DataCreateCallbackCalled for each trianing data input/output pair to create the entire training data set.

Functions

TrainingData

public TrainingData()

Default constructor creates an empty training data.  Use ReadTrainFromFile, SetTrainData or CreateTrainFromCallback to initialize.

TrainingData

public TrainingData(string filename)

Reads a file that stores training data.

See also

ReadTrainFromFile, SetTrainData or CreateTrainFromCallback

TrainingData

public TrainingData(TrainingData data)

Copy constructor constructs a copy of the training data.  Corresponds to the C API fann_duplicate_train_data function.

Dispose

public void Dispose()

Disposes of the training data.

ReadTrainFromFile

public bool ReadTrainFromFile(string filename)

Reads a file that stores training data.

The file must be formatted like

TrainDataLength InputCount OutputCount
inputdata seperated by space
outputdata seperated by space

.
.
.

inputdata seperated by space
outputdata seperated by space

See also

NeuralNet::TrainOnData, SaveTrain, fann_read_train_from_file

This function appears in FANN >= 1.0.0

SaveTrain

public bool SaveTrain(string filename)

Save the training structure to a file, with the format as specified in ReadTrainFromFile

Return

The function returns true on success and false on failure.

See also

ReadTrainFromFile, SaveTrainToFixed, fann_save_train

This function appears in FANN >= 1.0.0.

SaveTrainToFixed

public bool SaveTrainToFixed(string filename,
uint decimalPoint)

Saves the training structure to a fixed point data file.

This function is very useful for testing the quality of a fixed point network.

Return

The function returns true on success and false on failure.

See also

SaveTrain, fann_save_train_to_fixed

This function appears in FANN >= 1.0.0.

ShuffleTrainData

public void ShuffleTrainData()

Shuffles training data, randomizing the order.  This is recommended for incremental training, while it have no influence during batch training.

This function appears in FANN >= 1.1.0.

MergeTrainData

public void MergeTrainData(TrainingData data)

Merges the data into the data contained in the TrainingData.

This function appears in FANN >= 1.1.0.

Properties

TrainDataLength

public uint TrainDataLength { get }

Returns the number of training patterns in the TrainingData.

See also

InputCount, OutputCount, fann_length_train_data

This function appears in FANN >= 2.0.0.

InputCount

public uint InputCount { get }

Returns the number of inputs in each of the training patterns in the TrainingData.

See also

OutputCount, TrainDataLength, fann_num_input_train_data

This function appears in FANN >= 2.0.0.

OutputCount

public uint OutputCount { get }

Returns the number of outputs in each of the training patterns in the TrainingData.

See also

InputCount, TrainDataLength, fann_num_output_train_data

This function appears in FANN >= 2.0.0.

Input

public double[][] Input { get }

Grant access to the encapsulated data since many situations and applications creates the data from sources other than files or uses the training data for testing and related functions.

If you only need a specfic output data then it is preferrable to use the GetTrainInput method as this property has to duplicate the entirity of the input data in the managed layer.

If you need repeated fast access to all input data consider using InputAccessor

Returns

A array of arrays of input training data

See also

Output, InputAccessor, SetTrainData

This function appears in FANN >= 2.0.0.

InputAccessor

public ArrayAccessor InputAccessor { get }

An alternative to Input that returns an accessor object that grants access to to the input data with no copying.

Returns

A ArrayAccessor that can access the input arrray

See also

Input, SetTrainData

Output

public double[][] Output { get }

Grant access to the encapsulated data since many situations and applications creates the data from sources other than files or uses the training data for testing and related functions.

If you only need a specfic output data then it is preferrable to use the GetTrainOutput method as this property has to duplicate the entirity of the output data in the managed layer.

If you need repeated fast access to all output data consider using OutputAccessor

Returns

A arrray of arrays of output training data

See also

Input, OutputAccessor, SetTrainData

This function appears in FANN >= 2.0.0.

OutputAccessor

public ArrayAccessor OutputAccessor { get }

An alternative to Output that returns an accessor object that grants access to to the input data with no copying.

Returns

A ArrayAccessor that can access the output arrray

See also

Output, SetTrainData

Functions

GetTrainInput

public DataAccessor GetTrainInput(uint position)

Gets the training input data at the given position

Returns

An array of input training data at the given position

See also

GetTrainOutput, SetTrainData

This function appears in FANN >= 2.3.0.

GetTrainOutput

public DataAccessor GetTrainOutput(uint position)

Gets the training output data at the given position

Returns

An array of output training data at the given position

See also

GetTrainInput

This function appears in FANN >= 2.3.0.

SetTrainData

public void SetTrainData(double[][] input,
double[][] output)

Set the training data to the input and output data provided.

A copy of the data is made so there are no restrictions on the allocation of the input/output data.

Parameters

inputThe set of inputs (an array of arrays of double data)
outputThe set of desired outputs (an array of arrays of double data)

See also

Input, Output

SetTrainData

public void SetTrainData(uint dataLength,
double[] input,
double[] output)

Set the training data to the input and output data provided.

A copy of the data is made so there are no restrictions on the allocation of the input/output data..

Parameters

dataLengthThe number of training data
inputThe set of inputs (an array with the dimension dataLength*inputCount)
outputThe set of desired outputs (an array with the dimension dataLength*inputCount)

See also

Input, Output

CreateTrainFromCallback

public void CreateTrainFromCallback(uint dataCount,
uint inputCount,
uint outputCount,
DataCreateCallback callback)

Creates the training data from a user supplied function.  As the training data are numerable (data 1, data 2...), the user must write a function that receives the number of the training data set (input,output) and returns the set.

Parameters

dataCountThe number of training data
inputCountThe number of inputs per training data
outputCountThe number of ouputs per training data
callbackThe user suplied delegate

Parameters for the user delegate

numberThe number of the training data set
inputCountThe number of inputs per training data
outputCountThe number of ouputs per training data
inputThe set of inputs
outputThe set of desired outputs

See also

ReadTrainFromFile, NeuralNet::TrainOnData, fann_create_train_from_callback

This function appears in FANN >= 2.1.0

Properties

MinInput

public double MinInput { get }

Get the minimum value of all in the input data

This function appears in FANN >= 2.3.0

MaxInput

public double MaxInput { get }

Get the maximum value of all in the input data

This function appears in FANN >= 2.3.0

MinOutput

public double MinOutput { get }

Get the minimum value of all in the output data

This function appears in FANN >= 2.3.0

MaxOutput

public double MaxOutput { get }

Get the maximum value of all in the output data

This function appears in FANN >= 2.3.0

Functions

ScaleInputTrainData

public void ScaleInputTrainData(double new_min,
double new_max)

Scales the inputs in the training data to the specified range.

A simplified scaling method, which is mostly useful in examples where it’s known that all the data will be in one range and it should be transformed to another range.

It is not recommended to use this on subsets of data as the complete input range might not be available in that subset.

For more powerful scaling, please consider NeuralNet::ScaleTrain

See also

ScaleOutputTrainData, ScaleTrainData, fann_scale_input_train_data

This function appears in FANN >= 2.0.0.

ScaleOutputTrainData

public void ScaleOutputTrainData(double new_min,
double new_max)

Scales the outputs in the training data to the specified range.

A simplified scaling method, which is mostly useful in examples where it’s known that all the data will be in one range and it should be transformed to another range.

It is not recommended to use this on subsets of data as the complete input range might not be available in that subset.

For more powerful scaling, please consider NeuralNet::ScaleTrain

See also

ScaleInputTrainData, ScaleTrainData, fann_scale_output_train_data

This function appears in FANN >= 2.0.0.

ScaleTrainData

public void ScaleTrainData(double new_min,
double new_max)

Scales the inputs and outputs in the training data to the specified range.

A simplified scaling method, which is mostly useful in examples where it’s known that all the data will be in one range and it should be transformed to another range.

It is not recommended to use this on subsets of data as the complete input range might not be available in that subset.

For more powerful scaling, please consider NeuralNet::ScaleTrain

See also

ScaleOutputTrainData, ScaleInputTrainData, fann_scale_train_data

This function appears in FANN >= 2.0.0.

SubsetTrainData

public void SubsetTrainData(uint pos,
uint length)

Changes the training data to a subset, starting at position pos and length elements forward.  Use the copy constructor to work on a new copy of the training data.

TrainingData fullDataSet = new TrainingData();
fullDataSet.ReadTrainFromFile("somefile.train");
TrainingData smallDataSet = new TrainingData(fullDataSet);
smallDataSet->SubsetTrainData(0, 2); // Only use first two
// Use smallDataSet ...
small_data_set.Dispose();

See also

<fann_subset_train_data http://libfann.github.io/fann/docs/files/fann_train-h.html#fann_subset_train_data>

This function appears in FANN >= 2.0.0.

Delegates

DataCreateCallback

public delegate void DataCreateCallback(uint number,
uint inputCount,
uint outputCount,
double[] input,
double[] output)

Called for each trianing data input/output pair to create the entire training data set.

Parameters for the user function

numberThe number of the training data set
inputCountThe number of inputs per training data
outputCountThe number of ouputs per training data
inputThe set of inputs
outputThe set of desired outputs

See also

CreateTrainFromCallback, fann_create_train_from_callback

public TrainingData()
Default constructor creates an empty training data.
NeuralNet is the main neural network class used for both training and execution using doubles
public void Dispose()
Disposes of the training data.
public bool ReadTrainFromFile(string filename)
Reads a file that stores training data.
public bool SaveTrain(string filename)
Save the training structure to a file, with the format as specified in ReadTrainFromFile
public bool SaveTrainToFixed(string filename,
uint decimalPoint)
Saves the training structure to a fixed point data file.
public void ShuffleTrainData()
Shuffles training data, randomizing the order.
public void MergeTrainData(TrainingData data)
Merges the data into the data contained in the TrainingData.
public uint TrainDataLength { get }
Returns the number of training patterns in the TrainingData.
public uint InputCount { get }
Returns the number of inputs in each of the training patterns in the TrainingData.
public uint OutputCount { get }
Returns the number of outputs in each of the training patterns in the TrainingData.
public double[][] Input { get }
Grant access to the encapsulated data since many situations and applications creates the data from sources other than files or uses the training data for testing and related functions.
public ArrayAccessor InputAccessor { get }
An alternative to Input that returns an accessor object that grants access to to the input data with no copying.
public double[][] Output { get }
Grant access to the encapsulated data since many situations and applications creates the data from sources other than files or uses the training data for testing and related functions.
public ArrayAccessor OutputAccessor { get }
An alternative to Output that returns an accessor object that grants access to to the input data with no copying.
public DataAccessor GetTrainInput(uint position)
Gets the training input data at the given position
public DataAccessor GetTrainOutput(uint position)
Gets the training output data at the given position
public void SetTrainData(double[][] input,
double[][] output)
Set the training data to the input and output data provided.
public void CreateTrainFromCallback(uint dataCount,
uint inputCount,
uint outputCount,
DataCreateCallback callback)
Creates the training data from a user supplied function.
public double MinInput { get }
Get the minimum value of all in the input data
public double MaxInput { get }
Get the maximum value of all in the input data
public double MinOutput { get }
Get the minimum value of all in the output data
public double MaxOutput { get }
Get the maximum value of all in the output data
public void ScaleInputTrainData(double new_min,
double new_max)
Scales the inputs in the training data to the specified range.
public void ScaleOutputTrainData(double new_min,
double new_max)
Scales the outputs in the training data to the specified range.
public void ScaleTrainData(double new_min,
double new_max)
Scales the inputs and outputs in the training data to the specified range.
public void SubsetTrainData(uint pos,
uint length)
Changes the training data to a subset, starting at position pos and length elements forward.
public delegate void DataCreateCallback(uint number,
uint inputCount,
uint outputCount,
double[] input,
double[] output)
Called for each trianing data input/output pair to create the entire training data set.
public void TrainOnData(TrainingData data,
uint maxEpochs,
uint epochsBetweenReports,
float desiredError)
Trains on an entire dataset, for a period of time.
Provides fast access to an array of array of doubles
public void ScaleTrain(TrainingData data)
Scale input and output data based on previously calculated parameters.
Close