00001 /****************************************************************************************************************/ 00002 /* */ 00003 /* Flood: An Open Source Neural Networks C++ Library */ 00004 /* www.cimne.com/flood */ 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 #include "ObjectiveFunctional.h" 00021 #include "../Utilities/InputTargetDataSet.h" 00022 00023 namespace Flood 00024 { 00025 00028 00029 class MeanSquaredError : public ObjectiveFunctional 00030 { 00031 00032 public: 00033 00034 // DEFAULT CONSTRUCTOR 00035 00036 explicit MeanSquaredError(void); 00037 00038 // MULTILAYER PERCEPTRON CONSTRUCTOR 00039 00040 explicit MeanSquaredError(MultilayerPerceptron*); 00041 00042 // INPUT-TARGET DATA SET CONSTRUCTOR 00043 00044 explicit MeanSquaredError(InputTargetDataSet*); 00045 00046 // GENERAL CONSTRUCTOR 00047 00048 explicit MeanSquaredError(MultilayerPerceptron*, InputTargetDataSet*); 00049 00050 // DESTRUCTOR 00051 00052 virtual ~MeanSquaredError(void); 00053 00054 00055 // METHODS 00056 00057 // Get methods 00058 00061 00062 inline InputTargetDataSet* get_input_target_data_set_pointer(void) 00063 { 00064 return(input_target_data_set_pointer); 00065 } 00066 00067 // Set methods 00068 00069 void set(void); 00070 void set(MultilayerPerceptron*); 00071 void set(InputTargetDataSet*); 00072 void set(MultilayerPerceptron*, InputTargetDataSet*); 00073 00074 void set_input_target_data_set_pointer(InputTargetDataSet*); 00075 00076 // Evaluation methods 00077 00078 double calculate_objective(void); 00079 00080 // Gradient methods 00081 00082 Vector<double> calculate_output_errors(const Vector< Vector<double> >&, const Vector<double>&); 00083 Vector< Vector<double> > calculate_hidden_errors(const Vector< Vector<double> >&, const Vector<double>&); 00084 Vector<double> calculate_hidden_layers_error_gradient(const Vector<double>&, const Vector< Vector<double> >&, const Vector< Vector<double> >&); 00085 Vector<double> calculate_output_layer_error_gradient(const Vector< Vector<double> >&, const Vector<double>&); 00086 00087 Vector<double> calculate_objective_gradient(void); 00088 00089 // Jacobian methods 00090 00091 Matrix<double> calculate_Jacobian(void); 00092 00093 // Validation error methods 00094 00095 double calculate_validation_error(void); 00096 00097 private: 00098 00099 // MEMBERS 00100 00102 00103 InputTargetDataSet* input_target_data_set_pointer; 00104 00105 }; 00106 00107 } 00108 00109 #endif 00110 00111 00112 // Flood: An Open Source Neural Networks C++ Library. 00113 // Copyright (C) 2005-2010 Roberto Lopez 00114 // 00115 // This library is free software; you can redistribute it and/or 00116 // modify it under the s of the GNU Lesser General Public 00117 // License as published by the Free Software Foundation; either 00118 // version 2.1 of the License, or any later version. 00119 // 00120 // This library is distributed in the hope that it will be useful, 00121 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00122 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00123 // Lesser General Public License for more details. 00124 00125 // You should have received a copy of the GNU Lesser General Public 00126 // License along with this library; if not, write to the Free Software 00127 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA