OpenNN  2.2
Open Neural Networks Library
sum_squared_error.h
1 /****************************************************************************************************************/
2 /* */
3 /* OpenNN: Open Neural Networks Library */
4 /* www.artelnics.com/opennn */
5 /* */
6 /* S U M S Q U A R E D E R R O R C L A S S H E A D E R */
7 /* */
8 /* Roberto Lopez */
9 /* Artelnics - Making intelligent use of data */
11 /* */
12 /****************************************************************************************************************/
13 
14 #ifndef __SUMSQUAREDERROR_H__
15 #define __SUMSQUAREDERROR_H__
16 
17 // System includes
18 
19 #include <iostream>
20 #include <fstream>
21 #include <cmath>
22 #include <sstream>
23 #include <string>
24 #include <limits>
25 
26 // OpenNN includes
27 
28 #include "performance_term.h"
29 #include "data_set.h"
30 
31 // TinyXml includes
32 
33 #include "../tinyxml2/tinyxml2.h"
34 
35 namespace OpenNN
36 {
37 
41 
43 {
44 
45 public:
46 
47  // DEFAULT CONSTRUCTOR
48 
49  explicit SumSquaredError(void);
50 
51  // NEURAL NETWORK CONSTRUCTOR
52 
53  explicit SumSquaredError(NeuralNetwork*);
54 
55  // DATA SET CONSTRUCTOR
56 
57  explicit SumSquaredError(DataSet*);
58 
59  // GENERAL CONSTRUCTOR
60 
62 
63  // XML CONSTRUCTOR
64 
65  explicit SumSquaredError(const tinyxml2::XMLDocument&);
66 
67  // COPY CONSTRUCTOR
68 
70 
71  // DESTRUCTOR
72 
73  virtual ~SumSquaredError(void);
74 
75  // METHODS
76 
77  // Get methods
78 
79  // Set methods
80 
81  // Checking methods
82 
83  void check(void) const;
84 
85  // performance methods
86 
87  double calculate_performance(void) const;
88 
89  double calculate_generalization_performance(void) const;
90 
92 
94 
95  double calculate_performance(const Vector<double>&) const;
96 
98 
100 
101  // Objective terms methods
102 
103  Vector<double> calculate_terms(void) const;
105 
107 
109 
110  // Squared errors methods
111 
113 
114  std::string write_performance_term_type(void) const;
115 
116  // Serialization methods
117 
118  tinyxml2::XMLDocument* to_XML(void) const;
119 
120  void from_XML(const tinyxml2::XMLDocument&);
121 
122 };
123 
124 }
125 
126 #endif
127 
128 
129 // OpenNN: Open Neural Networks Library.
130 // Copyright (c) 2005-2015 Roberto Lopez.
131 //
132 // This library is free software; you can redistribute it and/or
133 // modify it under the terms of the GNU Lesser General Public
134 // License as published by the Free Software Foundation; either
135 // version 2.1 of the License, or any later version.
136 //
137 // This library is distributed in the hope that it will be useful,
138 // but WITHOUT ANY WARRANTY; without even the implied warranty of
139 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
140 // Lesser General Public License for more details.
141 
142 // You should have received a copy of the GNU Lesser General Public
143 // License along with this library; if not, write to the Free Software
144 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
double calculate_performance(void) const
Returns the performance value of a neural network according to the sum squared error on a data set...
double calculate_generalization_performance(void) const
Returns the sum squared error of the neural network measured on the generalization instances of the d...
tinyxml2::XMLDocument * to_XML(void) const
Returns a representation of the sum squared error object, in XML format.
virtual ~SumSquaredError(void)
Destructor.
Vector< double > calculate_gradient(void) const
Matrix< double > calculate_Hessian(void) const
Matrix< double > calculate_terms_Jacobian(void) const
void from_XML(const tinyxml2::XMLDocument &)
Vector< double > calculate_terms(void) const
Calculates the squared error terms for each instance, and returns it in a vector of size the number t...
PerformanceTerm::FirstOrderTerms calculate_first_order_terms(void) const
std::string write_performance_term_type(void) const
Returns a string with the name of the sum squared error performance type, "SUM_SQUARED_ERROR".
Vector< double > calculate_squared_errors(void) const
Returns the squared errors of the training instances.