CrossEntropyError Class Reference

This class represents the cross entropy error term, used for predicting probabilities. More...

#include <cross_entropy_error.h>

Inheritance diagram for CrossEntropyError:
LossIndex

Public Member Functions

 CrossEntropyError ()
 
 CrossEntropyError (NeuralNetwork *, DataSet *)
 
virtual ~CrossEntropyError ()
 Destructor. More...
 
void calculate_error (const DataSetBatch &, const NeuralNetworkForwardPropagation &, LossIndexBackPropagation &) const
 
void calculate_binary_error (const DataSetBatch &, const NeuralNetworkForwardPropagation &, LossIndexBackPropagation &) const
 
void calculate_multiple_error (const DataSetBatch &batch, const NeuralNetworkForwardPropagation &, LossIndexBackPropagation &) const
 
void calculate_output_delta (const DataSetBatch &, NeuralNetworkForwardPropagation &, LossIndexBackPropagation &) const
 
void calculate_binary_output_delta (const DataSetBatch &, NeuralNetworkForwardPropagation &, LossIndexBackPropagation &) const
 
void calculate_multiple_output_delta (const DataSetBatch &, NeuralNetworkForwardPropagation &, LossIndexBackPropagation &) const
 
string get_error_type () const
 Returns a string with the name of the cross entropy error loss type, "CROSS_ENTROPY_ERROR". More...
 
string get_error_type_text () const
 Returns a string with the name of the cross entropy 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 *)
 
virtual void set_data_set_pointer (DataSet *)
 Sets a new data set on which the error term is to be measured. More...
 
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 &)
 
virtual void set_normalization_coefficient ()
 
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
 
virtual void calculate_error_lm (const DataSetBatch &, const NeuralNetworkForwardPropagation &, LossIndexBackPropagationLM &) const
 
virtual void calculate_output_delta_lm (const DataSetBatch &, NeuralNetworkForwardPropagation &, LossIndexBackPropagationLM &) const
 
void calculate_layers_delta_lm (const DataSetBatch &, NeuralNetworkForwardPropagation &, LossIndexBackPropagationLM &) const
 
virtual void calculate_error_gradient_lm (const DataSetBatch &, LossIndexBackPropagationLM &) const
 
void calculate_squared_errors_jacobian_lm (const DataSetBatch &, NeuralNetworkForwardPropagation &, LossIndexBackPropagationLM &) const
 
virtual void calculate_error_hessian_lm (const DataSetBatch &, 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
 

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 cross entropy error term, used for predicting probabilities.

This functional is used in classification problems.

Definition at line 32 of file cross_entropy_error.h.

Constructor & Destructor Documentation

◆ CrossEntropyError() [1/2]

CrossEntropyError ( )
explicit

Default constructor. It creates a default cross entropy error term object, which is 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 cross_entropy_error.cpp.

◆ CrossEntropyError() [2/2]

CrossEntropyError ( NeuralNetwork new_neural_network_pointer,
DataSet new_data_set_pointer 
)
explicit

Neural network and data set constructor. It creates a cross entropy error term object 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 30 of file cross_entropy_error.cpp.

◆ ~CrossEntropyError()

~CrossEntropyError ( )
virtual

Destructor.

Definition at line 38 of file cross_entropy_error.cpp.

Member Function Documentation

◆ calculate_binary_error()

void calculate_binary_error ( const DataSetBatch batch,
const NeuralNetworkForwardPropagation forward_propagation,
LossIndexBackPropagation back_propagation 
) const

Definition at line 83 of file cross_entropy_error.cpp.

◆ calculate_binary_output_delta()

void calculate_binary_output_delta ( const DataSetBatch batch,
NeuralNetworkForwardPropagation forward_propagation,
LossIndexBackPropagation back_propagation 
) const

Definition at line 147 of file cross_entropy_error.cpp.

◆ calculate_error()

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

Implements LossIndex.

Definition at line 48 of file cross_entropy_error.cpp.

◆ calculate_multiple_error()

void calculate_multiple_error ( const DataSetBatch batch,
const NeuralNetworkForwardPropagation forward_propagation,
LossIndexBackPropagation back_propagation 
) const

Definition at line 104 of file cross_entropy_error.cpp.

◆ calculate_multiple_output_delta()

void calculate_multiple_output_delta ( const DataSetBatch batch,
NeuralNetworkForwardPropagation forward_propagation,
LossIndexBackPropagation back_propagation 
) const

Definition at line 171 of file cross_entropy_error.cpp.

◆ calculate_output_delta()

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

Implements LossIndex.

Definition at line 124 of file cross_entropy_error.cpp.

◆ from_XML()

void from_XML ( const tinyxml2::XMLDocument document)

Deserializes a TinyXML document into this cross entropy object.

Parameters
documentTinyXML document containing the member data.

Definition at line 224 of file cross_entropy_error.cpp.

◆ get_error_type()

string get_error_type ( ) const
virtual

Returns a string with the name of the cross entropy error loss type, "CROSS_ENTROPY_ERROR".

Reimplemented from LossIndex.

Definition at line 194 of file cross_entropy_error.cpp.

◆ get_error_type_text()

string get_error_type_text ( ) const
virtual

Returns a string with the name of the cross entropy error loss type in text format.

Reimplemented from LossIndex.

Definition at line 202 of file cross_entropy_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 211 of file cross_entropy_error.cpp.


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