00001 /****************************************************************************************************************/ 00002 /* */ 00003 /* OpenNN: Open Neural Networks Library */ 00004 /* www.opennn.cimne.com */ 00005 /* */ 00006 /* 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 */ 00007 /* */ 00008 /* Roberto Lopez */ 00009 /* International Center for Numerical Methods in Engineering (CIMNE) */ 00010 /* Technical University of Catalonia (UPC) */ 00011 /* Barcelona, Spain */ 00012 /* E-mail: rlopez@cimne.upc.edu */ 00013 /* */ 00014 /****************************************************************************************************************/ 00015 00016 #ifndef __SUMSQUAREDERROR_H__ 00017 #define __SUMSQUAREDERROR_H__ 00018 00019 #include "performance_functional.h" 00020 #include "../data_set/data_set.h" 00021 00022 namespace OpenNN 00023 { 00024 00028 00029 class SumSquaredError : public PerformanceTerm 00030 { 00031 00032 public: 00033 00034 // DEFAULT CONSTRUCTOR 00035 00036 explicit SumSquaredError(void); 00037 00038 // NEURAL NETWORK CONSTRUCTOR 00039 00040 explicit SumSquaredError(NeuralNetwork*); 00041 00042 // DATA SET CONSTRUCTOR 00043 00044 explicit SumSquaredError(DataSet*); 00045 00046 // GENERAL CONSTRUCTOR 00047 00048 explicit SumSquaredError(NeuralNetwork*, DataSet*); 00049 00050 // XML CONSTRUCTOR 00051 00052 explicit SumSquaredError(TiXmlElement*); 00053 00054 // COPY CONSTRUCTOR 00055 00056 SumSquaredError(const SumSquaredError&); 00057 00058 // DESTRUCTOR 00059 00060 virtual ~SumSquaredError(void); 00061 00062 // METHODS 00063 00064 // Get methods 00065 00066 // Set methods 00067 00068 // Checking methods 00069 00070 void check(void) const; 00071 00072 // Evaluation methods 00073 00074 double calculate_evaluation(void) const; 00075 double calculate_evaluation(const Vector<double>&) const; 00076 00077 double calculate_generalization_evaluation(void) const; 00078 00079 Vector<double> calculate_gradient(void) const; 00080 00081 Matrix<double> calculate_Hessian(void) const; 00082 00083 // Objective terms methods 00084 00085 Vector<double> calculate_evaluation_terms(void) const; 00086 Vector<double> calculate_evaluation_terms(const Vector<double>&) const; 00087 00088 Matrix<double> calculate_Jacobian_terms(void) const; 00089 00090 PerformanceTerm::FirstOrderEvaluationTerms calculate_first_order_evaluation_terms(void) const; 00091 00092 // Squared errors methods 00093 00094 Vector<double> calculate_squared_errors(void) const; 00095 00096 std::string write_performance_term_type(void) const; 00097 00098 // Serialization methods 00099 00100 TiXmlElement* to_XML(void) const; 00101 00102 void from_XML(TiXmlElement*); 00103 00104 }; 00105 00106 } 00107 00108 #endif 00109 00110 00111 // OpenNN: Open Neural Networks Library. 00112 // Copyright (C) 2005-2012 Roberto Lopez 00113 // 00114 // This library is free software; you can redistribute it and/or 00115 // modify it under the terms of the GNU Lesser General Public 00116 // License as published by the Free Software Foundation; either 00117 // version 2.1 of the License, or any later version. 00118 // 00119 // This library is distributed in the hope that it will be useful, 00120 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00121 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00122 // Lesser General Public License for more details. 00123 00124 // You should have received a copy of the GNU Lesser General Public 00125 // License along with this library; if not, write to the Free Software 00126 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA