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