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