NormalizedSquaredError Class Reference

This class represents the normalized squared error term. More...

#include <normalized_squared_error.h>

Inheritance diagram for NormalizedSquaredError:
LossIndex

Public Member Functions

 NormalizedSquaredError (NeuralNetwork *, DataSet *)
 
 NormalizedSquaredError ()
 
virtual ~NormalizedSquaredError ()
 Destructor. More...
 
type get_normalization_coefficient () const
 Returns the normalization coefficient. More...
 
type get_selection_normalization_coefficient () const
 Returns the selection normalization coefficient. More...
 
void set_normalization_coefficient ()
 
void set_normalization_coefficient (const type &)
 
void set_time_series_normalization_coefficient ()
 
void set_selection_normalization_coefficient ()
 
void set_selection_normalization_coefficient (const type &)
 
void set_default ()
 Sets the default values. More...
 
void set_data_set_pointer (DataSet *new_data_set_pointer)
 set_data_set_pointer More...
 
type calculate_normalization_coefficient (const Tensor< type, 2 > &, const Tensor< type, 1 > &) const
 
type calculate_time_series_normalization_coefficient (const Tensor< type, 2 > &, const Tensor< type, 2 > &) const
 
void calculate_error (const DataSetBatch &, const NeuralNetworkForwardPropagation &, LossIndexBackPropagation &) const
 NormalizedSquaredError::calculate_error. More...
 
void calculate_output_delta (const DataSetBatch &, NeuralNetworkForwardPropagation &, LossIndexBackPropagation &) const
 
void calculate_error_lm (const DataSetBatch &, const NeuralNetworkForwardPropagation &, LossIndexBackPropagationLM &) const
 
void calculate_output_delta_lm (const DataSetBatch &, NeuralNetworkForwardPropagation &, LossIndexBackPropagationLM &) const
 
void calculate_error_gradient_lm (const DataSetBatch &, LossIndexBackPropagationLM &) const
 
void calculate_error_hessian_lm (const DataSetBatch &, LossIndexBackPropagationLM &) const
 
string get_error_type () const
 Returns a string with the name of the normalized squared error loss type, "NORMALIZED_SQUARED_ERROR". More...
 
string get_error_type_text () const
 Returns a string with the name of the normalized squared error loss type in text format. More...
 
void from_XML (const tinyxml2::XMLDocument &)
 
void write_XML (tinyxml2::XMLPrinter &) const
 
- Public Member Functions inherited from LossIndex
 LossIndex ()
 
 LossIndex (NeuralNetwork *, DataSet *)
 
virtual ~LossIndex ()
 Destructor. More...
 
NeuralNetworkget_neural_network_pointer () const
 Returns a pointer to the neural network object associated to the error term. More...
 
DataSetget_data_set_pointer () const
 Returns a pointer to the data set object associated to the error term. More...
 
const type & get_regularization_weight () const
 Returns regularization weight. More...
 
const bool & get_display () const
 
bool has_neural_network () const
 
bool has_data_set () const
 
RegularizationMethod get_regularization_method () const
 Returns the regularization method. More...
 
void set ()
 
void set (NeuralNetwork *)
 
void set (DataSet *)
 
void set (NeuralNetwork *, DataSet *)
 
void set (const LossIndex &)
 
void set_threads_number (const int &)
 
void set_neural_network_pointer (NeuralNetwork *)
 
void set_default ()
 Sets the members of the error term to their default values: More...
 
void set_regularization_method (const RegularizationMethod &)
 
void set_regularization_method (const string &)
 
void set_regularization_weight (const type &)
 
void set_display (const bool &)
 
bool has_selection () const
 Returns true if there are selection samples and false otherwise. More...
 
type calculate_eta () const
 
type calculate_h (const type &) const
 
Tensor< type, 1 > calculate_gradient_numerical_differentiation ()
 
Tensor< type, 2 > calculate_jacobian_numerical_differentiation ()
 
void calculate_errors (const DataSetBatch &, const NeuralNetworkForwardPropagation &, LossIndexBackPropagation &) const
 
void calculate_layers_delta (const DataSetBatch &, NeuralNetworkForwardPropagation &, LossIndexBackPropagation &) const
 
void calculate_error_gradient (const DataSetBatch &, const NeuralNetworkForwardPropagation &, LossIndexBackPropagation &) const
 
void back_propagate (const DataSetBatch &, NeuralNetworkForwardPropagation &, LossIndexBackPropagation &) const
 
void calculate_errors_lm (const DataSetBatch &, const NeuralNetworkForwardPropagation &, LossIndexBackPropagationLM &) const
 
virtual void calculate_squared_errors_lm (const DataSetBatch &, const NeuralNetworkForwardPropagation &, LossIndexBackPropagationLM &) const
 
void calculate_layers_delta_lm (const DataSetBatch &, NeuralNetworkForwardPropagation &, LossIndexBackPropagationLM &) const
 
void calculate_squared_errors_jacobian_lm (const DataSetBatch &, NeuralNetworkForwardPropagation &, LossIndexBackPropagationLM &) const
 
void back_propagate_lm (const DataSetBatch &, NeuralNetworkForwardPropagation &, LossIndexBackPropagationLM &) const
 
type calculate_regularization (const Tensor< type, 1 > &) const
 
void calculate_regularization_gradient (const Tensor< type, 1 > &, Tensor< type, 1 > &) const
 
void calculate_regularization_hessian (const Tensor< type, 1 > &, Tensor< type, 2 > &) const
 
void from_XML (const tinyxml2::XMLDocument &)
 
void regularization_from_XML (const tinyxml2::XMLDocument &)
 
void write_regularization_XML (tinyxml2::XMLPrinter &) const
 
string write_regularization_method () const
 
void check () const
 

Private Attributes

type normalization_coefficient = type(NAN)
 Coefficient of normalization for the calculation of the training error. More...
 
type selection_normalization_coefficient = type(NAN)
 

Additional Inherited Members

- Public Types inherited from LossIndex
enum class  RegularizationMethod { L1 , L2 , NoRegularization }
 Enumeration of available regularization methods. More...
 
- Protected Attributes inherited from LossIndex
NonBlockingThreadPool * non_blocking_thread_pool = nullptr
 
ThreadPoolDevice * thread_pool_device = nullptr
 
NeuralNetworkneural_network_pointer = nullptr
 Pointer to a neural network object. More...
 
DataSetdata_set_pointer = nullptr
 Pointer to a data set object. More...
 
RegularizationMethod regularization_method = RegularizationMethod::L2
 Pointer to a regularization method object. More...
 
type regularization_weight = static_cast<type>(0.01)
 Regularization weight value. More...
 
bool display = true
 Display messages to screen. More...
 
const Eigen::array< IndexPair< Index >, 1 > AT_B = {IndexPair<Index>(0, 0)}
 
const Eigen::array< IndexPair< Index >, 1 > A_B = {IndexPair<Index>(1, 0)}
 
const Eigen::array< IndexPair< Index >, 2 > SSE = {IndexPair<Index>(0, 0), IndexPair<Index>(1, 1)}
 
const Eigen::array< int, 1 > rows_sum = {Eigen::array<int, 1>({1})}
 

Detailed Description

This class represents the normalized squared error term.

This error term is used in data modeling problems. If it has a value of unity then the neural network is predicting the data "in the mean", A value of zero means perfect prediction of data.

Definition at line 37 of file normalized_squared_error.h.

Constructor & Destructor Documentation

◆ NormalizedSquaredError() [1/2]

NormalizedSquaredError ( NeuralNetwork new_neural_network_pointer,
DataSet new_data_set_pointer 
)
explicit

Neural network and data set constructor. It creates a normalized squared error term associated to a neural network and measured on a data set. It also initializes all the rest of class members to their default values.

Parameters
new_neural_network_pointerPointer to a neural network object.
new_data_set_pointerPointer to a data set object.

Definition at line 31 of file normalized_squared_error.cpp.

◆ NormalizedSquaredError() [2/2]

NormalizedSquaredError ( )
explicit

Default constructor. It creates a normalized squared error term object not associated to any neural network and not measured on any data set. It also initializes all the rest of class members to their default values.

Definition at line 19 of file normalized_squared_error.cpp.

◆ ~NormalizedSquaredError()

~NormalizedSquaredError ( )
virtual

Destructor.

Definition at line 40 of file normalized_squared_error.cpp.

Member Function Documentation

◆ calculate_error()

void calculate_error ( const DataSetBatch batch,
const NeuralNetworkForwardPropagation ,
LossIndexBackPropagation back_propagation 
) const
virtual

NormalizedSquaredError::calculate_error.

Parameters
batch
forward_propagation
back_propagation

Implements LossIndex.

Definition at line 282 of file normalized_squared_error.cpp.

◆ calculate_error_gradient_lm()

void calculate_error_gradient_lm ( const DataSetBatch batch,
LossIndexBackPropagationLM loss_index_back_propagation_lm 
) const
virtual

Reimplemented from LossIndex.

Definition at line 465 of file normalized_squared_error.cpp.

◆ calculate_error_hessian_lm()

void calculate_error_hessian_lm ( const DataSetBatch batch,
LossIndexBackPropagationLM loss_index_back_propagation_lm 
) const
virtual

Reimplemented from LossIndex.

Definition at line 480 of file normalized_squared_error.cpp.

◆ calculate_error_lm()

void calculate_error_lm ( const DataSetBatch batch,
const NeuralNetworkForwardPropagation ,
LossIndexBackPropagationLM back_propagation 
) const
virtual

Reimplemented from LossIndex.

Definition at line 314 of file normalized_squared_error.cpp.

◆ calculate_normalization_coefficient()

type calculate_normalization_coefficient ( const Tensor< type, 2 > &  targets,
const Tensor< type, 1 > &  targets_mean 
) const

Returns the normalization coefficient to be used for the loss of the error. This is measured on the training samples of the data set.

Parameters
targetsMatrix with the targets values from data_set.
targets_meanVector with the means of the given targets.

Definition at line 238 of file normalized_squared_error.cpp.

◆ calculate_output_delta()

void calculate_output_delta ( const DataSetBatch batch,
NeuralNetworkForwardPropagation ,
LossIndexBackPropagation back_propagation 
) const
virtual

Implements LossIndex.

Definition at line 345 of file normalized_squared_error.cpp.

◆ calculate_output_delta_lm()

void calculate_output_delta_lm ( const DataSetBatch ,
NeuralNetworkForwardPropagation ,
LossIndexBackPropagationLM loss_index_back_propagation 
) const
virtual

Reimplemented from LossIndex.

Definition at line 410 of file normalized_squared_error.cpp.

◆ calculate_time_series_normalization_coefficient()

type calculate_time_series_normalization_coefficient ( const Tensor< type, 2 > &  targets_t_1,
const Tensor< type, 2 > &  targets_t 
) const

Definition at line 133 of file normalized_squared_error.cpp.

◆ from_XML()

void from_XML ( const tinyxml2::XMLDocument document)

Loads a root mean squared error object from a XML document.

Parameters
documentPointer to a TinyXML document with the object data.

Definition at line 533 of file normalized_squared_error.cpp.

◆ get_error_type()

string get_error_type ( ) const
virtual

Returns a string with the name of the normalized squared error loss type, "NORMALIZED_SQUARED_ERROR".

Reimplemented from LossIndex.

Definition at line 503 of file normalized_squared_error.cpp.

◆ get_error_type_text()

string get_error_type_text ( ) const
virtual

Returns a string with the name of the normalized squared error loss type in text format.

Reimplemented from LossIndex.

Definition at line 511 of file normalized_squared_error.cpp.

◆ get_normalization_coefficient()

type get_normalization_coefficient ( ) const

Returns the normalization coefficient.

Definition at line 47 of file normalized_squared_error.cpp.

◆ get_selection_normalization_coefficient()

type get_selection_normalization_coefficient ( ) const

Returns the selection normalization coefficient.

Definition at line 55 of file normalized_squared_error.cpp.

◆ set_data_set_pointer()

void set_data_set_pointer ( DataSet new_data_set_pointer)
virtual

set_data_set_pointer

Parameters
new_data_set_pointer

Reimplemented from LossIndex.

Definition at line 65 of file normalized_squared_error.cpp.

◆ set_default()

void set_default ( )

Sets the default values.

Definition at line 218 of file normalized_squared_error.cpp.

◆ set_normalization_coefficient() [1/2]

void set_normalization_coefficient ( )
virtual

Sets the normalization coefficient from training samples. This method calculates the normalization coefficient of the data_set.

Reimplemented from LossIndex.

Definition at line 83 of file normalized_squared_error.cpp.

◆ set_normalization_coefficient() [2/2]

void set_normalization_coefficient ( const type &  new_normalization_coefficient)

Sets the normalization coefficient.

Parameters
new_normalization_coefficientNew normalization coefficient to be set.

Definition at line 178 of file normalized_squared_error.cpp.

◆ set_selection_normalization_coefficient() [1/2]

void set_selection_normalization_coefficient ( )

Sets the normalization coefficient from selection samples. This method calculates the normalization coefficient of the data_set.

Definition at line 187 of file normalized_squared_error.cpp.

◆ set_selection_normalization_coefficient() [2/2]

void set_selection_normalization_coefficient ( const type &  new_selection_normalization_coefficient)

Sets the normalization coefficient from selection samples.

Parameters
new_normalization_coefficientNew normalization coefficient to be set.

Definition at line 210 of file normalized_squared_error.cpp.

◆ set_time_series_normalization_coefficient()

void set_time_series_normalization_coefficient ( )
Todo:
What is targets_t1 ???

Definition at line 101 of file normalized_squared_error.cpp.

◆ write_XML()

void write_XML ( tinyxml2::XMLPrinter file_stream) const
virtual

Serializes the cross entropy error object into a XML document of the TinyXML library without keep the DOM tree in memory. See the OpenNN manual for more information about the format of this document

Reimplemented from LossIndex.

Definition at line 520 of file normalized_squared_error.cpp.

Member Data Documentation

◆ normalization_coefficient

type normalization_coefficient = type(NAN)
private

Coefficient of normalization for the calculation of the training error.

Definition at line 116 of file normalized_squared_error.h.

◆ selection_normalization_coefficient

type selection_normalization_coefficient = type(NAN)
private

Definition at line 118 of file normalized_squared_error.h.


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