FANN C++ Training Data | |
training_data | training_data is used to create and manipulate training data used by the neural_net |
Functions | |
training_data | Default constructor creates an empty training data. |
training_data | Copy constructor constructs a copy of the training data. |
~training_data | Provides automatic cleanup of data. |
destroy | Destructs the training data. |
read_train_from_file | Reads a file that stores training data. |
save_train | Save the training structure to a file, with the format as specified in read_train_from_file |
save_train_to_fixed | Saves the training structure to a fixed point data file. |
shuffle_train_data | Shuffles training data, randomizing the order. |
merge_train_data | Merges the data into the data contained in the training_data. |
length_train_data | Returns the number of training patterns in the training_data. |
num_input_train_data | Returns the number of inputs in each of the training patterns in the training_data. |
num_output_train_data | Returns the number of outputs in each of the training patterns in the struct fann_train_data. |
get_input | 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 |
get_output | 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 |
get_train_input | Gets the training input data at the given position |
get_train_output | Gets the training output data at the given position |
set_train_data | Set the training data to the input and output data provided. |
set_train_data | Set the training data to the input and output data provided. |
create_train_from_callback | Creates the training data struct from a user supplied function. |
get_min_input | Get the minimum value of all in the input data |
get_max_input | Get the maximum value of all in the input data |
get_min_output | Get the minimum value of all in the output data |
get_max_output | Get the maximum value of all in the output data |
scale_input_train_data | Scales the inputs in the training data to the specified range. |
scale_output_train_data | Scales the outputs in the training data to the specified range. |
scale_train_data | Scales the inputs and outputs in the training data to the specified range. |
subset_train_data | Changes the training data to a subset, starting at position pos and length elements forward. |
class training_data
training_data is used to create and manipulate training data used by the neural_net
Encapsulation of a training data set struct fann_train_data and associated C API functions.
Functions | |
training_data | Default constructor creates an empty training data. |
training_data | Copy constructor constructs a copy of the training data. |
~training_data | Provides automatic cleanup of data. |
destroy | Destructs the training data. |
read_train_from_file | Reads a file that stores training data. |
save_train | Save the training structure to a file, with the format as specified in read_train_from_file |
save_train_to_fixed | Saves the training structure to a fixed point data file. |
shuffle_train_data | Shuffles training data, randomizing the order. |
merge_train_data | Merges the data into the data contained in the training_data. |
length_train_data | Returns the number of training patterns in the training_data. |
num_input_train_data | Returns the number of inputs in each of the training patterns in the training_data. |
num_output_train_data | Returns the number of outputs in each of the training patterns in the struct fann_train_data. |
get_input | 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 |
get_output | 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 |
get_train_input | Gets the training input data at the given position |
get_train_output | Gets the training output data at the given position |
set_train_data | Set the training data to the input and output data provided. |
set_train_data | Set the training data to the input and output data provided. |
create_train_from_callback | Creates the training data struct from a user supplied function. |
get_min_input | Get the minimum value of all in the input data |
get_max_input | Get the maximum value of all in the input data |
get_min_output | Get the minimum value of all in the output data |
get_max_output | Get the maximum value of all in the output data |
scale_input_train_data | Scales the inputs in the training data to the specified range. |
scale_output_train_data | Scales the outputs in the training data to the specified range. |
scale_train_data | Scales the inputs and outputs in the training data to the specified range. |
subset_train_data | Changes the training data to a subset, starting at position pos and length elements forward. |
training_data( ) : train_data(NULL)
Default constructor creates an empty training data. Use read_train_from_file, set_train_data or create_train_from_callback to initialize.
training_data( const training_data & data )
Copy constructor constructs a copy of the training data. Corresponds to the C API fann_duplicate_train_data function.
bool read_train_from_file( const std:: string & filename )
Reads a file that stores training data.
num_train_data num_input num_output inputdata seperated by space outputdata seperated by space . . . inputdata seperated by space outputdata seperated by space
neural_net::train_on_data, save_train, fann_read_train_from_file
This function appears in FANN >= 1.0.0
bool save_train( const std:: string & filename )
Save the training structure to a file, with the format as specified in read_train_from_file
The function returns true on success and false on failure.
read_train_from_file, save_train_to_fixed, fann_save_train
This function appears in FANN >= 1.0.0.
bool save_train_to_fixed( const std:: string & filename, unsigned int decimal_point )
Saves the training structure to a fixed point data file.
This function is very useful for testing the quality of a fixed point network.
The function returns true on success and false on failure.
save_train, fann_save_train_to_fixed
This function appears in FANN >= 1.0.0.
void merge_train_data( const training_data & data )
Merges the data into the data contained in the training_data.
This function appears in FANN >= 1.1.0.
unsigned int length_train_data()
Returns the number of training patterns in the training_data.
num_input_train_data, num_output_train_data, fann_length_train_data
This function appears in FANN >= 2.0.0.
unsigned int num_input_train_data()
Returns the number of inputs in each of the training patterns in the training_data.
num_output_train_data, length_train_data, fann_num_input_train_data
This function appears in FANN >= 2.0.0.
unsigned int num_output_train_data()
Returns the number of outputs in each of the training patterns in the struct fann_train_data.
num_input_train_data, length_train_data, fann_num_output_train_data
This function appears in FANN >= 2.0.0.
fann_type **get_input()
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
A pointer to the array of input training data
This function appears in FANN >= 2.0.0.
fann_type **get_output()
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
A pointer to the array of output training data
This function appears in FANN >= 2.0.0.
fann_type *get_train_input( unsigned int position )
Gets the training input data at the given position
A pointer to the array of input training data at the given position
get_train_output, set_train_data
This function appears in FANN >= 2.3.0.
void set_train_data( unsigned int num_data, unsigned int num_input, fann_type ** input, unsigned int num_output, fann_type ** 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 and the caller is responsible for the deallocation of the data pointed to by input and output.
num_data | The number of training data |
num_input | The number of inputs per training data |
num_output | The number of ouputs per training data |
input | The set of inputs (a pointer to an array of pointers to arrays of floating point data) |
output | The set of desired outputs (a pointer to an array of pointers to arrays of floating point data) |
void set_train_data( unsigned int num_data, unsigned int num_input, fann_type * input, unsigned int num_output, fann_type * 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 and the caller is responsible for the deallocation of the data pointed to by input and output.
num_data | The number of training data |
num_input | The number of inputs per training data |
num_output | The number of ouputs per training data |
input | The set of inputs (an array with the dimension num_data*num_input) |
output | The set of desired outputs (an array with the dimension num_data*num_output) |
void create_train_from_callback( unsigned int num_data, unsigned int num_input, unsigned int num_output, void (FANN_API *user_function)(unsigned int, unsigned int, unsigned int, fann_type *, fann_type *) )
Creates the training data struct 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.
num_data | The number of training data |
num_input | The number of inputs per training data |
num_output | The number of ouputs per training data |
user_function | The user suplied function |
num | The number of the training data set |
num_input | The number of inputs per training data |
num_output | The number of ouputs per training data |
input | The set of inputs |
output | The set of desired outputs |
training_data::read_train_from_file, neural_net::train_on_data, fann_create_train_from_callback
This function appears in FANN >= 2.1.0
void scale_input_train_data( fann_type new_min, fann_type 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 neural_net::scale_train
scale_output_train_data, scale_train_data, fann_scale_input_train_data
This function appears in FANN >= 2.0.0.
void scale_output_train_data( fann_type new_min, fann_type 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 neural_net::scale_train
scale_input_train_data, scale_train_data, fann_scale_output_train_data
This function appears in FANN >= 2.0.0.
void scale_train_data( fann_type new_min, fann_type 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 neural_net::scale_train
scale_output_train_data, scale_input_train_data, fann_scale_train_data
This function appears in FANN >= 2.0.0.
void subset_train_data( unsigned int pos, unsigned int 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.
FANN::training_data full_data_set; full_data_set.read_train_from_file("somefile.train"); FANN::training_data *small_data_set = new FANN::training_data(full_data_set); small_data_set->subset_train_data(0, 2); // Only use first two // Use small_data_set ... delete small_data_set;
This function appears in FANN >= 2.0.0.
training_data is used to create and manipulate training data used by the neural_net
class training_data
Default constructor creates an empty training data.
training_data( ) : train_data(NULL)
neural_net is the main neural network class used for both training and execution
class neural_net
Provides automatic cleanup of data.
#ifdef USE_VIRTUAL_DESTRUCTOR virtual #endif ~training_data()
Destructs the training data.
void destroy_train()
Reads a file that stores training data.
bool read_train_from_file( const std:: string & filename )
Save the training structure to a file, with the format as specified in read_train_from_file
bool save_train( const std:: string & filename )
Saves the training structure to a fixed point data file.
bool save_train_to_fixed( const std:: string & filename, unsigned int decimal_point )
Shuffles training data, randomizing the order.
void shuffle_train_data()
Merges the data into the data contained in the training_data.
void merge_train_data( const training_data & data )
Returns the number of training patterns in the training_data.
unsigned int length_train_data()
Returns the number of inputs in each of the training patterns in the training_data.
unsigned int num_input_train_data()
Returns the number of outputs in each of the training patterns in the struct fann_train_data.
unsigned int num_output_train_data()
Structure used to store data, for use with training.
struct fann_train_data
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
fann_type **get_input()
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
fann_type **get_output()
Gets the training input data at the given position
fann_type *get_train_input( unsigned int position )
Gets the training output data at the given position
fann_type *get_train_output( unsigned int position )
Set the training data to the input and output data provided.
void set_train_data( unsigned int num_data, unsigned int num_input, fann_type ** input, unsigned int num_output, fann_type ** output )
Creates the training data struct from a user supplied function.
void create_train_from_callback( unsigned int num_data, unsigned int num_input, unsigned int num_output, void (FANN_API *user_function)(unsigned int, unsigned int, unsigned int, fann_type *, fann_type *) )
Get the minimum value of all in the input data
fann_type get_min_input()
Get the maximum value of all in the input data
fann_type get_max_input()
Get the minimum value of all in the output data
fann_type get_min_output()
Get the maximum value of all in the output data
fann_type get_max_output()
Scales the inputs in the training data to the specified range.
void scale_input_train_data( fann_type new_min, fann_type new_max )
Scales the outputs in the training data to the specified range.
void scale_output_train_data( fann_type new_min, fann_type new_max )
Scales the inputs and outputs in the training data to the specified range.
void scale_train_data( fann_type new_min, fann_type new_max )
Changes the training data to a subset, starting at position pos and length elements forward.
void subset_train_data( unsigned int pos, unsigned int length )
Returns an exact copy of a struct fann_train_data.
FANN_EXTERNAL struct fann_train_data *FANN_API fann_duplicate_train_data( struct fann_train_data * data )
Trains on an entire dataset, for a period of time.
void train_on_data( const training_data & data, unsigned int max_epochs, unsigned int epochs_between_reports, float desired_error )
Reads a file that stores training data.
FANN_EXTERNAL struct fann_train_data *FANN_API fann_read_train_from_file( const char * filename )
Save the training structure to a file, with the format as specified in fann_read_train_from_file
FANN_EXTERNAL int FANN_API fann_save_train( struct fann_train_data * data, const char * filename )
Saves the training structure to a fixed point data file.
FANN_EXTERNAL int FANN_API fann_save_train_to_fixed( struct fann_train_data * data, const char * filename, unsigned int decimal_point )
Returns the number of training patterns in the struct fann_train_data.
FANN_EXTERNAL unsigned int FANN_API fann_length_train_data( struct fann_train_data * data )
Returns the number of inputs in each of the training patterns in the struct fann_train_data.
FANN_EXTERNAL unsigned int FANN_API fann_num_input_train_data( struct fann_train_data * data )
Returns the number of outputs in each of the training patterns in the struct fann_train_data.
FANN_EXTERNAL unsigned int FANN_API fann_num_output_train_data( struct fann_train_data * data )
Creates the training data struct from a user supplied function.
FANN_EXTERNAL struct fann_train_data * FANN_API fann_create_train_from_callback( unsigned int num_data, unsigned int num_input, unsigned int num_output, void (FANN_API *user_function)( unsigned int, unsigned int, unsigned int, fann_type * , fann_type * ) )
Scale input and output data based on previously calculated parameters.
void scale_train( training_data & data )
Scales the inputs in the training data to the specified range.
FANN_EXTERNAL void FANN_API fann_scale_input_train_data( struct fann_train_data * train_data, fann_type new_min, fann_type new_max )
Scales the outputs in the training data to the specified range.
FANN_EXTERNAL void FANN_API fann_scale_output_train_data( struct fann_train_data * train_data, fann_type new_min, fann_type new_max )
Scales the inputs and outputs in the training data to the specified range.
FANN_EXTERNAL void FANN_API fann_scale_train_data( struct fann_train_data * train_data, fann_type new_min, fann_type new_max )
Returns an copy of a subset of the struct fann_train_data, starting at position pos and length elements forward.
FANN_EXTERNAL struct fann_train_data *FANN_API fann_subset_train_data( struct fann_train_data * data, unsigned int pos, unsigned int length )