OpenNN  2.2
Open Neural Networks Library
Public Types | Public Member Functions | Protected Attributes | List of all members
OpenNN::ScalingLayer Class Reference

#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)
 
ScalingLayeroperator= (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 ScalingMethodget_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
 

Detailed Description

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.

Constructor & Destructor Documentation

OpenNN::ScalingLayer::ScalingLayer ( void  )
explicit

Default constructor. It creates a scaling layer object with no scaling neurons.

Definition at line 26 of file scaling_layer.cpp.

OpenNN::ScalingLayer::ScalingLayer ( const size_t &  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.

Parameters
new_scaling_neurons_numberNumber of scaling neurons in the layer.

Definition at line 39 of file scaling_layer.cpp.

OpenNN::ScalingLayer::ScalingLayer ( const Vector< Statistics< double > > &  new_statistics)
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.

Parameters
new_statisticsVector of vectors with the variables statistics.

Definition at line 52 of file scaling_layer.cpp.

Member Function Documentation

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.

Parameters
inputsVector 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.

Parameters
inputsVector 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.

Vector< double > OpenNN::ScalingLayer::calculate_outputs ( const Vector< double > &  inputs) const

Scales some values to produce some scaled values.

Parameters
inputsSet 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.

Parameters
inputsSet of inputs to the scaling layer.

Definition at line 599 of file scaling_layer.cpp.

void OpenNN::ScalingLayer::from_XML ( const tinyxml2::XMLDocument &  document)
virtual

Deserializes a TinyXML document into this scaling layer object.

Parameters
documentXML 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.

Parameters
indexNeuron 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.

Parameters
other_scaling_layerObject 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.

Parameters
other_scaling_layerObject 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.

Parameters
indexIndex 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.

Parameters
new_statisticsVector 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.

Parameters
new_scaling_layer_documentPointer 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.

Parameters
new_scaling_layerObject to be copied.

Definition at line 355 of file scaling_layer.cpp.

void OpenNN::ScalingLayer::set_default ( void  )
virtual

Sets the members to their default value:

  • Minimus: -1 for all unscaling neurons.
  • Maximums: 1 for al unscaling neurons.
  • Means: 0 for all unscaling neurons.
  • Standard deviations 1 for all unscaling neurons.
  • Scaling method: Minimum and maximum.
  • Display: True.

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.

Parameters
new_displayDisplay 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.

Parameters
iIndex of neuron.
item_statisticsStatistics 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.

Parameters
iIndex of scaling neuron.
new_maximumMaximum 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.

Parameters
iIndex of scaling neuron.
new_meanMean 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.

Parameters
iIndex of scaling neuron.
new_minimumMinimum 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.

Parameters
new_scaling_methodNew 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").

Parameters
new_scaling_methodNew 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.

Parameters
iIndex of scaling neuron.
new_standard_deviationStandard 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.

Parameters
new_statisticsScaling 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.

Parameters
inputs_nameName of inputs to the scaling layer. The size of this vector must be equal to the number of scaling neurons.
outputs_nameName 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.

Parameters
inputs_nameName of inputs to the scaling layer. The size of this vector must be equal to the number of scaling neurons.
outputs_nameName 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.

Parameters
inputs_nameName of inputs to the scaling layer. The size of this vector must be equal to the number of scaling neurons.
outputs_nameName 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.


The documentation for this class was generated from the following files: