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