normalized_squared_error.h
1// OpenNN: Open Neural Networks Library
2// www.opennn.net
3//
4// N O R M A L I Z E D S Q U A R E D E R R O R C L A S S H E A D E R
5//
6// Artificial Intelligence Techniques SL
7// artelnics@artelnics.com
8
9#ifndef NORMALIZEDSQUAREDERROR_H
10#define NORMALIZEDSQUAREDERROR_H
11
12// System includes
13
14#include <cmath>
15#include <iostream>
16#include <fstream>
17#include <limits>
18#include <string>
19#include <sstream>
20
21// OpenNN includes
22
23#include "config.h"
24#include "loss_index.h"
25#include "data_set.h"
26
27namespace OpenNN
28{
29
31
36
38{
39
40public:
41
42 // Constructors
43
45
46 explicit NormalizedSquaredError();
47
48 // Destructor
49
51
52 // Get methods
53
56
57 // Set methods
58
60 void set_normalization_coefficient(const type&);
61
63
66
67 void set_default();
68
69 void set_data_set_pointer(DataSet* new_data_set_pointer);
70
71 // Normalization coefficients
72
73 type calculate_normalization_coefficient(const Tensor<type, 2>&, const Tensor<type, 1>&) const;
74
75 type calculate_time_series_normalization_coefficient(const Tensor<type, 2>&, const Tensor<type, 2>&) const;
76
77 // Back propagation
78
79 void calculate_error(const DataSetBatch&,
82
83 void calculate_output_delta(const DataSetBatch&,
86
87 // Back propagation LM
88
89 void calculate_error_lm(const DataSetBatch&,
92
93 void calculate_output_delta_lm(const DataSetBatch&,
96
97 void calculate_error_gradient_lm(const DataSetBatch&,
99
100 void calculate_error_hessian_lm(const DataSetBatch&,
102
103 // Serialization methods
104
105 string get_error_type() const;
106 string get_error_type_text() const;
107
108 void from_XML(const tinyxml2::XMLDocument&);
109
110 void write_XML(tinyxml2::XMLPrinter&) const;
111
112private:
113
115
117
118 type selection_normalization_coefficient = type(NAN);
119
120#ifdef OPENNN_CUDA
121 #include "../../opennn-cuda/opennn-cuda/normalized_squared_error_cuda.h"
122#endif
123
124};
125
126}
127
128#endif
129
130
131// OpenNN: Open Neural Networks Library.
132// Copyright(C) 2005-2021 Artificial Intelligence Techniques, SL.
133//
134// This library is free software; you can redistribute it and/or
135// modify it under the terms of the GNU Lesser General Public
136// License as published by the Free Software Foundation; either
137// version 2.1 of the License, or any later version.
138//
139// This library is distributed in the hope that it will be useful,
140// but WITHOUT ANY WARRANTY; without even the implied warranty of
141// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
142// Lesser General Public License for more details.
143
144// You should have received a copy of the GNU Lesser General Public
145// License along with this library; if not, write to the Free Software
146// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
This class represents the concept of data set for data modelling problems, such as approximation,...
Definition: data_set.h:57
This abstract class represents the concept of loss index composed of an error term and a regularizati...
Definition: loss_index.h:48
This class represents the normalized squared error term.
type normalization_coefficient
Coefficient of normalization for the calculation of the training error.
type get_selection_normalization_coefficient() const
Returns the selection normalization coefficient.
void from_XML(const tinyxml2::XMLDocument &)
void set_default()
Sets the default values.
void calculate_error(const DataSetBatch &, const NeuralNetworkForwardPropagation &, LossIndexBackPropagation &) const
NormalizedSquaredError::calculate_error.
type get_normalization_coefficient() const
Returns the normalization coefficient.
string get_error_type() const
Returns a string with the name of the normalized squared error loss type, "NORMALIZED_SQUARED_ERROR".
type calculate_normalization_coefficient(const Tensor< type, 2 > &, const Tensor< type, 1 > &) const
void set_data_set_pointer(DataSet *new_data_set_pointer)
set_data_set_pointer
void write_XML(tinyxml2::XMLPrinter &) const
string get_error_type_text() const
Returns a string with the name of the normalized squared error loss type in text format.
A loss index composed of several terms, this structure represent the First Order for this function.
Definition: loss_index.h:383