OpenNN
2.2
Open Neural Networks Library
|
#include <scaling_layer.h>
Public Types | |
enum | ScalingMethod { NoScaling, MinimumMaximum, MeanStandardDeviation } |
Public Member Functions | |
ScalingLayer (void) | |
ScalingLayer (const size_t &) | |
ScalingLayer (const Vector< Statistics< double > > &) | |
ScalingLayer (const ScalingLayer &) | |
virtual | ~ScalingLayer (void) |
ScalingLayer & | operator= (const ScalingLayer &) |
bool | operator== (const ScalingLayer &) const |
size_t | get_scaling_neurons_number (void) const |
Vector< Statistics< double > > | get_statistics (void) const |
Statistics< double > | get_statistics (const size_t &) const |
Matrix< double > | arrange_statistics (void) const |
Vector< double > | arrange_means (void) const |
Vector< double > | arrange_standard_deviations (void) const |
const ScalingMethod & | get_scaling_method (void) const |
std::string | write_scaling_method (void) const |
std::string | write_scaling_method_text (void) const |
const bool & | get_display (void) const |
void | set (void) |
void | set (const size_t &) |
void | set (const Vector< Statistics< double > > &) |
void | set (const tinyxml2::XMLDocument &) |
void | set (const ScalingLayer &) |
virtual void | set_default (void) |
void | set_statistics (const Vector< Statistics< double > > &) |
void | set_item_statistics (const size_t &, const Statistics< double > &) |
void | set_minimum (const size_t &, const double &) |
void | set_maximum (const size_t &, const double &) |
void | set_mean (const size_t &, const double &) |
void | set_standard_deviation (const size_t &, const double &) |
void | set_scaling_method (const ScalingMethod &) |
void | set_scaling_method (const std::string &) |
void | set_display (const bool &) |
void | prune_scaling_neuron (const size_t &) |
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_derivatives (const Vector< double > &) const |
Vector< double > | calculate_second_derivatives (const Vector< double > &) const |
Vector< double > | calculate_minimum_maximum_outputs (const Vector< double > &) const |
Vector< double > | calculate_minimum_maximum_derivatives (const Vector< double > &) const |
Vector< double > | calculate_minimum_maximum_second_derivatives (const Vector< double > &) const |
Vector< double > | calculate_mean_standard_deviation_outputs (const Vector< double > &) const |
Vector< double > | calculate_mean_standard_deviation_derivatives (const Vector< double > &) const |
Vector< double > | calculate_mean_standard_deviation_second_derivatives (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_no_scaling_expression (const Vector< std::string > &, const Vector< std::string > &) 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 |
tinyxml2::XMLDocument * | to_XML (void) const |
virtual void | from_XML (const tinyxml2::XMLDocument &) |
Protected Attributes | |
Vector< Statistics< double > > | statistics |
ScalingMethod | scaling_method |
bool | display |
This class represents a layer of scaling neurons. Scaling layers are included in the definition of a neural network. They are used to normalize variables so they are in an appropriate range for computer processing.
Definition at line 42 of file scaling_layer.h.
|
explicit |
Default constructor. It creates a scaling layer object with no scaling neurons.
Definition at line 26 of file scaling_layer.cpp.
|
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 39 of file scaling_layer.cpp.
|
explicit |
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 52 of file scaling_layer.cpp.
Matrix< double > OpenNN::ScalingLayer::arrange_statistics | ( | void | ) | const |
Returns a single matrix with the statistics of all scaling neurons. The number of rows is the number of scaling neurons. The number of columns is four (minimum, maximum, mean and standard deviation).
Definition at line 160 of file scaling_layer.cpp.
Vector< double > OpenNN::ScalingLayer::calculate_derivatives | ( | 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 765 of file scaling_layer.cpp.
Vector< double > OpenNN::ScalingLayer::calculate_mean_standard_deviation_derivatives | ( | const Vector< double > & | ) | const |
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 958 of file scaling_layer.cpp.
Vector< double > OpenNN::ScalingLayer::calculate_mean_standard_deviation_outputs | ( | const Vector< double > & | inputs | ) | const |
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 923 of file scaling_layer.cpp.
Vector< double > OpenNN::ScalingLayer::calculate_mean_standard_deviation_second_derivatives | ( | const Vector< double > & | ) | const |
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 993 of file scaling_layer.cpp.
Vector< double > OpenNN::ScalingLayer::calculate_minimum_maximum_derivatives | ( | const Vector< double > & | ) | const |
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 873 of file scaling_layer.cpp.
Vector< double > OpenNN::ScalingLayer::calculate_minimum_maximum_outputs | ( | const Vector< double > & | inputs | ) | const |
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 838 of file scaling_layer.cpp.
Vector< double > OpenNN::ScalingLayer::calculate_minimum_maximum_second_derivatives | ( | const Vector< double > & | ) | const |
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 908 of file scaling_layer.cpp.
Scales some values to produce some scaled values.
inputs | Set of inputs to the scaling layer. |
Definition at line 698 of file scaling_layer.cpp.
Vector< double > OpenNN::ScalingLayer::calculate_second_derivatives | ( | 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 801 of file scaling_layer.cpp.
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 599 of file scaling_layer.cpp.
|
virtual |
Deserializes a TinyXML document into this scaling layer object.
document | XML document containing the member data. |
Definition at line 1281 of file scaling_layer.cpp.
const bool & OpenNN::ScalingLayer::get_display | ( | void | ) | const |
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 291 of file scaling_layer.cpp.
Vector< Statistics< double > > OpenNN::ScalingLayer::get_statistics | ( | void | ) | const |
Returns all the scaling layer statistics. The format is a vector of statistics structures of size the number of scaling neurons.
Definition at line 137 of file scaling_layer.cpp.
Statistics< double > OpenNN::ScalingLayer::get_statistics | ( | const size_t & | index | ) | const |
Returns the statistics structure of a single scaling neuron.
index | Neuron index. |
Definition at line 148 of file scaling_layer.cpp.
void OpenNN::ScalingLayer::initialize_random | ( | void | ) |
Initializes at random the statistics of all neurons in the layer and the unscaling method.
Definition at line 651 of file scaling_layer.cpp.
ScalingLayer & OpenNN::ScalingLayer::operator= | ( | const ScalingLayer & | other_scaling_layer | ) |
Assignment operator.
other_scaling_layer | Object to be copied. |
Definition at line 84 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 107 of file scaling_layer.cpp.
void OpenNN::ScalingLayer::prune_scaling_neuron | ( | const size_t & | index | ) |
Removes a given scaling neuron from the scaling layer.
index | Index of neuron to be removed. |
Definition at line 547 of file scaling_layer.cpp.
void OpenNN::ScalingLayer::set | ( | const size_t & | new_inputs_number | ) |
Sets a new size in the scaling layer. It also sets the members to their default values.
Definition at line 314 of file scaling_layer.cpp.
void OpenNN::ScalingLayer::set | ( | const Vector< Statistics< double > > & | new_statistics | ) |
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 329 of file scaling_layer.cpp.
void OpenNN::ScalingLayer::set | ( | const tinyxml2::XMLDocument & | new_scaling_layer_document | ) |
Sets the scaling layer members from a XML document.
new_scaling_layer_document | Pointer to a TinyXML document containing the member data. |
Definition at line 342 of file scaling_layer.cpp.
void OpenNN::ScalingLayer::set | ( | const ScalingLayer & | new_scaling_layer | ) |
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 355 of file scaling_layer.cpp.
|
virtual |
Sets the members to their default value:
Definition at line 377 of file scaling_layer.cpp.
void OpenNN::ScalingLayer::set_display | ( | const bool & | new_display | ) |
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 536 of file scaling_layer.cpp.
void OpenNN::ScalingLayer::set_item_statistics | ( | const size_t & | i, |
const Statistics< double > & | item_statistics | ||
) |
Sets the statistics of a single scaling neuron.
i | Index of neuron. |
item_statistics | Statistics structure for that neuron. |
Definition at line 431 of file scaling_layer.cpp.
void OpenNN::ScalingLayer::set_maximum | ( | const size_t & | i, |
const double & | new_maximum | ||
) |
Sets the maximum value of a given scaling neuron.
i | Index of scaling neuron. |
new_maximum | Maximum value. |
Definition at line 455 of file scaling_layer.cpp.
void OpenNN::ScalingLayer::set_mean | ( | const size_t & | i, |
const double & | new_mean | ||
) |
Sets the mean value of a given scaling neuron.
i | Index of scaling neuron. |
new_mean | Mean value. |
Definition at line 467 of file scaling_layer.cpp.
void OpenNN::ScalingLayer::set_minimum | ( | const size_t & | i, |
const double & | new_minimum | ||
) |
Sets the minimum value of a given scaling neuron.
i | Index of scaling neuron. |
new_minimum | Minimum value. |
Definition at line 443 of file scaling_layer.cpp.
void OpenNN::ScalingLayer::set_scaling_method | ( | const ScalingMethod & | new_scaling_method | ) |
Sets the method to be used for scaling the variables.
new_scaling_method | New scaling method for the variables. |
Definition at line 490 of file scaling_layer.cpp.
void OpenNN::ScalingLayer::set_scaling_method | ( | const std::string & | new_scaling_method | ) |
Sets the method to be used for scaling the variables. The argument is a string containing the name of the method ("NoScaling", "MeanStandardDeviation" or "MinimumMaximum").
new_scaling_method | New scaling method in the layer. |
Definition at line 502 of file scaling_layer.cpp.
void OpenNN::ScalingLayer::set_standard_deviation | ( | const size_t & | i, |
const double & | new_standard_deviation | ||
) |
Sets the standard deviation value of a given scaling neuron.
i | Index of scaling neuron. |
new_standard_deviation | Standard deviation value. |
Definition at line 479 of file scaling_layer.cpp.
void OpenNN::ScalingLayer::set_statistics | ( | const Vector< Statistics< double > > & | new_statistics | ) |
Sets all the scaling layer statistics from a vector statistics structures. The size of the vector must be equal to the number of scaling neurons in the layer.
new_statistics | Scaling layer statistics. |
Definition at line 396 of file scaling_layer.cpp.
tinyxml2::XMLDocument * OpenNN::ScalingLayer::to_XML | ( | void | ) | const |
Serializes the scaling layer object into a XML document of the TinyXML library. See the OpenNN manual for more information about the format of this element.
Definition at line 1178 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 |
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 1089 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 |
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 1068 of file scaling_layer.cpp.
std::string OpenNN::ScalingLayer::write_no_scaling_expression | ( | const Vector< std::string > & | inputs_name, |
const Vector< std::string > & | outputs_name | ||
) | const |
Returns a string with the expression of the scaling process when the none method is used.
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 1046 of file scaling_layer.cpp.
std::string OpenNN::ScalingLayer::write_scaling_method_text | ( | void | ) | const |
Returns a string with the name of the method used for scaling, as paragaph text.
Definition at line 259 of file scaling_layer.cpp.