00001 /****************************************************************************************************************/ 00002 /* */ 00003 /* Flood: An Open Source Neural Networks C++ Library */ 00004 /* www.cimne.com/flood */ 00005 /* */ 00006 /* R O O T 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 __ROOTMEANSQUAREDERROR_H__ 00018 #define __ROOTMEANSQUAREDERROR_H__ 00019 00020 #include "ObjectiveFunctional.h" 00021 #include "../Utilities/InputTargetDataSet.h" 00022 00023 namespace Flood 00024 { 00025 00028 00029 class RootMeanSquaredError : public ObjectiveFunctional 00030 { 00031 00032 public: 00033 00034 // DEFAULT CONSTRUCTOR 00035 00036 explicit RootMeanSquaredError(void); 00037 00038 // MULTILAYER PERCEPTRON CONSTRUCTOR 00039 00040 explicit RootMeanSquaredError(MultilayerPerceptron*); 00041 00042 // INPUT-TARGET DATA SET CONSTRUCTOR 00043 00044 explicit RootMeanSquaredError(InputTargetDataSet*); 00045 00046 // GENERAL CONSTRUCTOR 00047 00048 explicit RootMeanSquaredError(MultilayerPerceptron*, InputTargetDataSet*); 00049 00050 // DESTRUCTOR 00051 00052 virtual ~RootMeanSquaredError(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 // Objective functional evaluation methods 00077 00078 double calculate_objective(void); 00079 double calculate_validation_error(void); 00080 00081 // Objective function gradient vector methods 00082 00083 Vector<double> calculate_output_errors(const Vector< Vector<double> >&, const Vector<double>&); 00084 Vector< Vector<double> > calculate_hidden_errors(const Vector< Vector<double> >&, const Vector<double>&); 00085 Vector<double> calculate_hidden_layers_error_gradient(const Vector<double>& input, const Vector< Vector<double> >&, const Vector< Vector<double> >&); 00086 Vector<double> calculate_output_layer_error_gradient(const Vector< Vector<double> >&, const Vector<double>&); 00087 00088 Vector<double> calculate_objective_gradient(void); 00089 00090 private: 00091 00092 // MEMBERS 00093 00095 00096 InputTargetDataSet* input_target_data_set_pointer; 00097 }; 00098 00099 } 00100 00101 #endif 00102 00103 00104 // Flood: An Open Source Neural Networks C++ Library. 00105 // Copyright (C) 2005-2010 Roberto Lopez 00106 // 00107 // This library is free software; you can redistribute it and/or 00108 // modify it under the s of the GNU Lesser General Public 00109 // License as published by the Free Software Foundation; either 00110 // version 2.1 of the License, or any later version. 00111 // 00112 // This library is distributed in the hope that it will be useful, 00113 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00114 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00115 // Lesser General Public License for more details. 00116 00117 // You should have received a copy of the GNU Lesser General Public 00118 // License along with this library; if not, write to the Free Software 00119 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA