#include <scaling_layer.h>
Public Types | |
enum | ScalingMethod { MinimumMaximum, MeanStandardDeviation } |
Public Member Functions | |
ScalingLayer (void) | |
ScalingLayer (const unsigned int &) | |
ScalingLayer (const Vector< Vector< double > > &) | |
ScalingLayer (const ScalingLayer &) | |
virtual | ~ScalingLayer (void) |
ScalingLayer & | operator= (const ScalingLayer &) |
bool | operator== (const ScalingLayer &) const |
unsigned int | count_scaling_neurons_number (void) const |
const Vector< double > & | get_minimums (void) const |
double | get_minimum (const unsigned int &) const |
const Vector< double > & | get_maximums (void) const |
double | get_maximum (const unsigned int &) const |
const Vector< double > & | get_means (void) const |
double | get_mean (const unsigned int &) const |
const Vector< double > & | get_standard_deviations (void) const |
double | get_standard_deviation (const unsigned int &) const |
Vector< Vector< double > * > | get_minimums_maximums (void) |
Vector< Vector< double > * > | get_means_standard_deviations (void) |
Vector< Vector< double > * > | get_statistics (void) |
const ScalingMethod & | get_scaling_method (void) const |
std::string | write_scaling_method (void) const |
const bool & | get_display (void) const |
void | set (void) |
void | set (const unsigned int &) |
void | set (const Vector< Vector< double > > &) |
void | set (TiXmlElement *) |
void | set (const ScalingLayer &) |
virtual void | set_default (void) |
void | set_minimums (const Vector< double > &) |
void | set_minimum (const unsigned int &, const double &) |
void | set_maximums (const Vector< double > &) |
void | set_maximum (const unsigned int &, const double &) |
void | set_means (const Vector< double > &) |
void | set_mean (const unsigned int &, const double &) |
void | set_standard_deviations (const Vector< double > &) |
void | set_standard_deviation (const unsigned int &, const double &) |
void | set_minimums_maximums (const Vector< Vector< double > > &) |
void | set_means_standard_deviations (const Vector< Vector< double > > &) |
void | set_statistics (const Vector< Vector< double > > &) |
void | set_scaling_method (const ScalingMethod &) |
void | set_scaling_method (const std::string &) |
void | set_display (const bool &) |
bool | is_empty (void) const |
void | initialize_random (void) |
void | check_range (const Vector< double > &) const |
Vector< double > | calculate_outputs (const Vector< double > &) const |
Vector< double > | calculate_derivative (const Vector< double > &) const |
Vector< double > | calculate_second_derivative (const Vector< double > &) const |
Vector< double > | calculate_minimum_maximum_output (const Vector< double > &) const |
Vector< double > | calculate_minimum_maximum_derivative (const Vector< double > &) const |
Vector< double > | calculate_minimum_maximum_second_derivative (const Vector< double > &) const |
Vector< double > | calculate_mean_standard_deviation_output (const Vector< double > &) const |
Vector< double > | calculate_mean_standard_deviation_derivative (const Vector< double > &) const |
Vector< double > | calculate_mean_standard_deviation_second_derivative (const Vector< double > &) const |
Matrix< double > | arrange_Jacobian (const Vector< double > &) const |
Vector< Matrix< double > > | arrange_Hessian_form (const Vector< double > &) const |
std::string | write_minimum_maximum_expression (const Vector< std::string > &, const Vector< std::string > &) const |
std::string | write_mean_standard_deviation_expression (const Vector< std::string > &, const Vector< std::string > &) const |
std::string | write_expression (const Vector< std::string > &, const Vector< std::string > &) const |
std::string | to_string (void) const |
TiXmlElement * | to_XML (void) const |
virtual void | from_XML (TiXmlElement *) |
Protected Attributes | |
Vector< double > | minimums |
Vector< double > | maximums |
Vector< double > | means |
Vector< double > | standard_deviations |
ScalingMethod | scaling_method |
bool | display |
Definition at line 39 of file scaling_layer.h.
Enumeration of available methods for scaling the input variables.
Definition at line 76 of file scaling_layer.h.
OpenNN::ScalingLayer::ScalingLayer | ( | void | ) | [explicit] |
Default constructor. It creates a scaling layer object with no scaling neurons.
Definition at line 37 of file scaling_layer.cpp.
OpenNN::ScalingLayer::ScalingLayer | ( | const unsigned int & | new_scaling_neurons_number | ) | [explicit] |
Scaling neurons number constructor. This constructor creates a scaling layer with a given size. The members of this object are initialized with the default values.
new_scaling_neurons_number | Number of scaling neurons in the layer. |
Definition at line 50 of file scaling_layer.cpp.
Statistics constructor. This constructor creates a scaling layer with given minimums, maximums, means and standard deviations. The rest of members of this object are initialized with the default values.
new_statistics | Vector of vectors with the variables statistics. |
Definition at line 63 of file scaling_layer.cpp.
OpenNN::ScalingLayer::ScalingLayer | ( | const ScalingLayer & | new_scaling_layer | ) |
OpenNN::ScalingLayer::~ScalingLayer | ( | void | ) | [virtual] |
ScalingLayer & OpenNN::ScalingLayer::operator= | ( | const ScalingLayer & | other_scaling_layer | ) |
Assignment operator.
other_scaling_layer | Object to be copied. |
Definition at line 95 of file scaling_layer.cpp.
bool OpenNN::ScalingLayer::operator== | ( | const ScalingLayer & | other_scaling_layer | ) | const |
Equal to operator. If compares this object with another object of the same class, and returns true if they are equal, and false otherwise.
other_scaling_layer | Object to be compared with. |
Definition at line 123 of file scaling_layer.cpp.
unsigned int OpenNN::ScalingLayer::count_scaling_neurons_number | ( | void | ) | const |
This method returns the number of unscaling neurons in this layer.
Definition at line 145 of file scaling_layer.cpp.
const Vector< double > & OpenNN::ScalingLayer::get_minimums | ( | void | ) | const |
This method returns the minimum values of all the scaling neurons. Such values are to be used for scaling variables with the minimums and maximums method.
Definition at line 207 of file scaling_layer.cpp.
double OpenNN::ScalingLayer::get_minimum | ( | const unsigned int & | i | ) | const |
This method returns the minimum value of a single neuron in the scaling layer. Such value is to be used for scaling that variable with the minimums and maximums method.
Definition at line 218 of file scaling_layer.cpp.
const Vector< double > & OpenNN::ScalingLayer::get_maximums | ( | void | ) | const |
This method returns the maximum values of the scaling layer. Such values are to be used for scaling variables with the minimums and maximums method.
Definition at line 156 of file scaling_layer.cpp.
double OpenNN::ScalingLayer::get_maximum | ( | const unsigned int & | i | ) | const |
This method returns the maximum value of a single variable. Such value is to be used for scaling that variable with the minimums and maximums method.
Definition at line 167 of file scaling_layer.cpp.
const Vector< double > & OpenNN::ScalingLayer::get_means | ( | void | ) | const |
This method returns the mean values of all the scaling neurons of the multilayer perceptron Such values are to be used for scaling inputs with the means and standard deviation method.
Definition at line 258 of file scaling_layer.cpp.
double OpenNN::ScalingLayer::get_mean | ( | const unsigned int & | index | ) | const |
This method returns the mean value of a single input variable of the multilayer perceptron Such a value is to be used for scaling that inputs with the means and standard deviation method.
index | Index of input variable. |
Definition at line 270 of file scaling_layer.cpp.
const Vector< double > & OpenNN::ScalingLayer::get_standard_deviations | ( | void | ) | const |
This method returns the standard deviation values of all the scaling neurons of the multilayer perceptron Such values are to be used for scaling inputs with the means and standard deviation method.
Definition at line 300 of file scaling_layer.cpp.
double OpenNN::ScalingLayer::get_standard_deviation | ( | const unsigned int & | index | ) | const |
This method returns the standard deviation value of a single input variable of the multilayer perceptron Such a value is to be used for scaling that inputs with the means and standard deviation method.
index | Index of input variable. |
Definition at line 312 of file scaling_layer.cpp.
This method returns the minimums and the maximum values of all the scaling neurons. The format is a vector of pointers to vectors of size two. The first element contains the minimum values of the scaling neurons. The second element contains the maximum values of the scaling neurons. Such values are to be used for scaling inputs with the minimums and maximums method.
Definition at line 345 of file scaling_layer.cpp.
This method returns the means and the standard deviation values of all the scaling neurons. The format is a vector of pointers to vectors of size two. The first element contains the mean values of the scaling neurons. The second element contains the standard deviation values of the scaling neurons. Such values are to be used for scaling inputs with the means and standard deviation method.
Definition at line 364 of file scaling_layer.cpp.
This method returns all the available statistics of the inputs and variables. The format is a vector of pointers to vectors of size ten:
Definition at line 386 of file scaling_layer.cpp.
const ScalingLayer::ScalingMethod & OpenNN::ScalingLayer::get_scaling_method | ( | void | ) | const |
std::string OpenNN::ScalingLayer::write_scaling_method | ( | void | ) | const |
This method returns a string with the name of the method used for scaling.
Definition at line 413 of file scaling_layer.cpp.
const bool & OpenNN::ScalingLayer::get_display | ( | void | ) | const |
This method returns true if messages from this class are to be displayed on the screen, or false if messages from this class are not to be displayed on the screen.
Definition at line 441 of file scaling_layer.cpp.
void OpenNN::ScalingLayer::set | ( | void | ) |
void OpenNN::ScalingLayer::set | ( | const unsigned int & | new_inputs_number | ) |
This method sets a new size in the scaling layer. It also sets the members to their default values.
Definition at line 467 of file scaling_layer.cpp.
This method sets the size of the scaling layer and the statistics values.
new_statistics | Vector of vectors containing the minimums, maximums, means and standard deviations for the scaling layer. The size of this vector must be 4. The size of each subvector will be the size of the scaling layer. |
Definition at line 485 of file scaling_layer.cpp.
void OpenNN::ScalingLayer::set | ( | TiXmlElement * | new_scaling_layer_element | ) |
This method sets the scaling layer members from a XML element.
new_scaling_layer_element | Pointer to a Tiny XML element containing the member data. |
Definition at line 501 of file scaling_layer.cpp.
void OpenNN::ScalingLayer::set | ( | const ScalingLayer & | new_scaling_layer | ) |
This method sets the members of this object to be the members of another object of the same class.
new_scaling_layer | Object to be copied. |
Definition at line 512 of file scaling_layer.cpp.
void OpenNN::ScalingLayer::set_default | ( | void | ) | [virtual] |
This method sets the members to their default value:
Definition at line 537 of file scaling_layer.cpp.
void OpenNN::ScalingLayer::set_minimums | ( | const Vector< double > & | new_minimums | ) |
This method sets new minimum values for all the scaling neurons. These values are used for scaling variables with the minimums and maximums method.
new_minimums | New set of minimum values for the scaling neurons. |
Definition at line 556 of file scaling_layer.cpp.
void OpenNN::ScalingLayer::set_minimum | ( | const unsigned int & | index, | |
const double & | new_minimum | |||
) |
This method sets a new minimum value for a single scaling neuron. This value is used for scaling that variable with the minimums and maximums method.
index | Index of scaling neuron. | |
new_minimum | New minimum value for the scaling neuron with the previous index. |
Definition at line 591 of file scaling_layer.cpp.
void OpenNN::ScalingLayer::set_maximums | ( | const Vector< double > & | new_maximum | ) |
This method sets new maximum values for all the scaling neurons. These values are used for scaling the inputs to the multilayer perceptron with the minimums and maximums method.
new_maximum | New set of maximum values for the scaling neurons of the multilayer perceptron |
Definition at line 629 of file scaling_layer.cpp.
void OpenNN::ScalingLayer::set_maximum | ( | const unsigned int & | index, | |
const double & | new_maximum | |||
) |
This method sets a new maximum value for a single input variable. This value is used for scaling that inputs to the multilayer perceptron with the minimums and maximums method.
index | Index of input variable. | |
new_maximum | New maximum value for that input variable. |
Definition at line 663 of file scaling_layer.cpp.
void OpenNN::ScalingLayer::set_means | ( | const Vector< double > & | new_mean | ) |
This method sets new mean values for all the scaling neurons. These values are used for scaling the inputs to the multilayer perceptron with the meand and standard deviation method.
new_mean | New set of mean values for the scaling neurons of the multilayer perceptron |
Definition at line 702 of file scaling_layer.cpp.
void OpenNN::ScalingLayer::set_mean | ( | const unsigned int & | index, | |
const double & | new_mean | |||
) |
This method sets a new mean value for a single input variable. These values are used for scaling the inputs to the multilayer perceptron with the meand and standard deviation method.
index | Index of input variable. | |
new_mean | New mean values for the input variable with index i. |
Definition at line 737 of file scaling_layer.cpp.
void OpenNN::ScalingLayer::set_standard_deviations | ( | const Vector< double > & | new_standard_deviation | ) |
This method sets new standard deviation values for all the scaling neurons. These values are used for scaling the inputs to the multilayer perceptron with the meand and standard deviation method.
new_standard_deviation | New set of standard deviation values for the scaling neurons of the multilayer perceptron |
Definition at line 779 of file scaling_layer.cpp.
void OpenNN::ScalingLayer::set_standard_deviation | ( | const unsigned int & | index, | |
const double & | new_standard_deviation | |||
) |
This method sets a new standard deviation value for a single input variable. These values are used for scaling the inputs to the multilayer perceptron with the meand and standard deviation method.
index | Index of input variable. | |
new_standard_deviation | New standard deviation value for that input variable. |
Definition at line 814 of file scaling_layer.cpp.
void OpenNN::ScalingLayer::set_minimums_maximums | ( | const Vector< Vector< double > > & | new_minimums_maximums | ) |
This method sets both the minimums and the maximum values of all the scaling neurons. The format is a vector of two real vectors. The first element must contain the minimum values for the scaling neurons. The second element must contain the maximum values for the scaling neurons. These values are used for scaling variables with the minimums and maximums method.
new_minimums_maximums | New set of minimums and maximum values for the scaling neurons of the layer. |
Definition at line 858 of file scaling_layer.cpp.
void OpenNN::ScalingLayer::set_means_standard_deviations | ( | const Vector< Vector< double > > & | new_means_standard_deviations | ) |
This method sets both the mean and the standard deviation values of all the scaling neurons. The format is a vector of two real vectors. The first element must contain the mean values for the scaling neurons. The second elements must contain the standard deviation values for the scaling neurons. These values are used for scaling variables with the meand and standard deviation method.
new_means_standard_deviations | New set of mean and standard deviation values for the scaling neurons. |
Definition at line 927 of file scaling_layer.cpp.
This method sets all the scaling layer statistics. The format is a vector of four real vectors:
new_statistics | Scaling layer statistics. |
Definition at line 993 of file scaling_layer.cpp.
void OpenNN::ScalingLayer::set_scaling_method | ( | const ScalingMethod & | new_scaling_method | ) |
This method sets the method to be used for scaling the variables.
new_scaling_method | New scaling method for the variables. |
Definition at line 1048 of file scaling_layer.cpp.
void OpenNN::ScalingLayer::set_scaling_method | ( | const std::string & | new_scaling_method | ) |
This method sets the method to be used for scaling the variables. The argument is a string containing the name of the method ("None", "MeanStandardDeviation" or "MinimumMaximum").
new_scaling_method | New scaling method in the layer. |
Definition at line 1060 of file scaling_layer.cpp.
void OpenNN::ScalingLayer::set_display | ( | const bool & | new_display | ) |
This method sets a new display value. If it is set to true messages from this class are to be displayed on the screen; if it is set to false messages from this class are not to be displayed on the screen.
new_display | Display value. |
Definition at line 1090 of file scaling_layer.cpp.
bool OpenNN::ScalingLayer::is_empty | ( | void | ) | const |
This method returns true if the number of scaling neurons is zero, and false otherwise.
Definition at line 1100 of file scaling_layer.cpp.
void OpenNN::ScalingLayer::initialize_random | ( | void | ) |
void OpenNN::ScalingLayer::check_range | ( | const Vector< double > & | inputs | ) | const |
This method chechs whether the inputs to the scaling layer have the right size. If not, it displays an error message and exits the program. It also checks whether the input values are inside the range defined by the minimums and maximum values, and displays a warning message if they are outside.
inputs | Set of inputs to the scaling layer. |
Definition at line 1123 of file scaling_layer.cpp.
This method scales some values to produce some scaled values.
inputs | Set of inputs to the scaling layer. |
Definition at line 1193 of file scaling_layer.cpp.
Vector< double > OpenNN::ScalingLayer::calculate_derivative | ( | const Vector< double > & | dummy | ) | const |
This method retuns the derivatives of the scaled inputs with respect to the raw inputs. That derivatives depend on the inputs scaling method to be used.
Definition at line 1250 of file scaling_layer.cpp.
Vector< double > OpenNN::ScalingLayer::calculate_second_derivative | ( | const Vector< double > & | dummy | ) | const |
This method retuns the second derivatives of the scaled inputs with respect to the raw inputs. That second derivatives depend on the inputs scaling method to be used.
Definition at line 1287 of file scaling_layer.cpp.
Vector< double > OpenNN::ScalingLayer::calculate_minimum_maximum_output | ( | const Vector< double > & | inputs | ) | const |
This method calculates the outputs from the scaling layer with the minimum and maximum method for a set of inputs.
inputs | Vector of input values to the scaling layer. The size must be equal to the number of scaling neurons. |
Definition at line 1324 of file scaling_layer.cpp.
Vector< double > OpenNN::ScalingLayer::calculate_minimum_maximum_derivative | ( | const Vector< double > & | ) | const |
This method calculates the derivatives of the outputs from the scaling layer with the minimum and maximum method. As the minimum and maximum method is a linear method, the derivatives will not depend on the inputs.
Definition at line 1359 of file scaling_layer.cpp.
Vector< double > OpenNN::ScalingLayer::calculate_minimum_maximum_second_derivative | ( | const Vector< double > & | ) | const |
This method calculates the second derivatives of the outputs from the scaling layer with the minimum and maximum method. As the minimum and maximum method is a linear method, the second derivatives will be always zero.
Definition at line 1394 of file scaling_layer.cpp.
Vector< double > OpenNN::ScalingLayer::calculate_mean_standard_deviation_output | ( | const Vector< double > & | inputs | ) | const |
This method calculates the outputs from the scaling layer with the mean and standard deviation method for a set of inputs.
inputs | Vector of input values to the scaling layer. The size must be equal to the number of scaling neurons. |
Definition at line 1409 of file scaling_layer.cpp.
Vector< double > OpenNN::ScalingLayer::calculate_mean_standard_deviation_derivative | ( | const Vector< double > & | ) | const |
This method calculates the derivatives of the outputs from the scaling layer with the mean and standard deviation method. As the minimum and maximum method is a linear method, the derivatives will not depend on the inputs.
Definition at line 1445 of file scaling_layer.cpp.
Vector< double > OpenNN::ScalingLayer::calculate_mean_standard_deviation_second_derivative | ( | const Vector< double > & | ) | const |
This method calculates the second derivatives of the outputs from the scaling layer with the mean and standard deviation method. As the minimum and maximum method is a linear method, the second derivatives will be always zero.
Definition at line 1480 of file scaling_layer.cpp.
Matrix< double > OpenNN::ScalingLayer::arrange_Jacobian | ( | const Vector< double > & | derivative | ) | const |
This method arranges a "Jacobian" matrix from the vector of derivatives.
Definition at line 1494 of file scaling_layer.cpp.
Vector< Matrix< double > > OpenNN::ScalingLayer::arrange_Hessian_form | ( | const Vector< double > & | second_derivative | ) | const |
This method arranges a "Hessian form" vector of matrices from the vector of second derivatives.
Definition at line 1510 of file scaling_layer.cpp.
std::string OpenNN::ScalingLayer::write_minimum_maximum_expression | ( | const Vector< std::string > & | inputs_name, | |
const Vector< std::string > & | outputs_name | |||
) | const |
This method returns a string with the expression of the scaling process with the minimum and maximum method.
inputs_name | Name of inputs to the scaling layer. The size of this vector must be equal to the number of scaling neurons. | |
outputs_name | Name of outputs from the scaling layer. The size of this vector must be equal to the number of scaling neurons. |
Definition at line 1533 of file scaling_layer.cpp.
std::string OpenNN::ScalingLayer::write_mean_standard_deviation_expression | ( | const Vector< std::string > & | inputs_name, | |
const Vector< std::string > & | outputs_name | |||
) | const |
This method returns a string with the expression of the scaling process with the mean and standard deviation method.
inputs_name | Name of inputs to the scaling layer. The size of this vector must be equal to the number of scaling neurons. | |
outputs_name | Name of outputs from the scaling layer. The size of this vector must be equal to the number of scaling neurons. |
Definition at line 1554 of file scaling_layer.cpp.
std::string OpenNN::ScalingLayer::write_expression | ( | const Vector< std::string > & | inputs_name, | |
const Vector< std::string > & | outputs_name | |||
) | const |
This method returns a string with the expression of the inputs scaling process.
Definition at line 1573 of file scaling_layer.cpp.
std::string OpenNN::ScalingLayer::to_string | ( | void | ) | const |
This method returns a string representation of the current scaling layer object.
Definition at line 1612 of file scaling_layer.cpp.
TiXmlElement * OpenNN::ScalingLayer::to_XML | ( | void | ) | const |
This method serializes the scaling layer object into a XML element of the TinyXML library. See the OpenNN manual for more information about the format of this element.
Definition at line 1633 of file scaling_layer.cpp.
void OpenNN::ScalingLayer::from_XML | ( | TiXmlElement * | scaling_layer_element | ) | [virtual] |
This method deserializes a TinyXML element into this scaling layer object.
scaling_layer_element | Pointer to a XML element containing the member data. |
Definition at line 1712 of file scaling_layer.cpp.
Vector<double> OpenNN::ScalingLayer::minimums [protected] |
Vector<double> OpenNN::ScalingLayer::maximums [protected] |
Vector<double> OpenNN::ScalingLayer::means [protected] |
Vector<double> OpenNN::ScalingLayer::standard_deviations [protected] |
ScalingMethod OpenNN::ScalingLayer::scaling_method [protected] |
bool OpenNN::ScalingLayer::display [protected] |