00001 /****************************************************************************************************************/ 00002 /* */ 00003 /* OpenNN: Open Neural Networks Library */ 00004 /* www.opennn.cimne.com */ 00005 /* */ 00006 /* T R A I N I N G A L G O R I T H M 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 __TRAININGALGORITHM_H__ 00017 #define __TRAININGALGORITHM_H__ 00018 00019 // OpenNN includes 00020 00021 #include "../performance_functional/performance_functional.h" 00022 00023 // TinyXml includes 00024 00025 #include "../../parsers/tinyxml/tinyxml.h" 00026 00027 namespace OpenNN 00028 { 00029 00032 00033 class TrainingAlgorithm 00034 { 00035 00036 public: 00037 00038 // DEFAULT CONSTRUCTOR 00039 00040 explicit TrainingAlgorithm(void); 00041 00042 // GENERAL CONSTRUCTOR 00043 00044 explicit TrainingAlgorithm(PerformanceFunctional*); 00045 00046 // XML CONSTRUCTOR 00047 00048 explicit TrainingAlgorithm(TiXmlElement*); 00049 00050 // DESTRUCTOR 00051 00052 virtual ~TrainingAlgorithm(void); 00053 00054 // STRUCTURES 00055 00059 00060 struct Results 00061 { 00063 00064 virtual std::string to_string(void) const 00065 { 00066 std::string str; 00067 00068 return(str); 00069 }; 00070 }; 00071 00072 // METHODS 00073 00074 // Get methods 00075 00076 PerformanceFunctional* get_performance_functional_pointer(void) const; 00077 00078 // Utilities 00079 00080 const bool& get_display(void) const; 00081 00082 // Set methods 00083 00084 void set(void); 00085 void set(PerformanceFunctional*); 00086 virtual void set_default(void); 00087 00088 void set_performance_functional_pointer(PerformanceFunctional*); 00089 00090 void set_display(const bool&); 00091 00092 // Training methods 00093 00094 virtual void check(void) const; 00095 00097 00098 virtual Results* perform_training(void) = 0; 00099 00100 virtual std::string write_training_algorithm_type(void) const; 00101 00102 // Serialization methods 00103 00104 virtual std::string to_string(void) const; 00105 void print(void) const; 00106 00107 virtual TiXmlElement* to_XML(void) const; 00108 virtual void from_XML(TiXmlElement*); 00109 00110 void save(const std::string&) const; 00111 void load(const std::string&); 00112 00113 protected: 00114 00115 // FIELDS 00116 00118 00119 PerformanceFunctional* performance_functional_pointer; 00120 00121 // UTILITIES 00122 00124 00125 bool display; 00126 }; 00127 00128 } 00129 00130 #endif 00131 00132 00133 // OpenNN: Open Neural Networks Library. 00134 // Copyright (C) 2005-2012 Roberto Lopez 00135 // 00136 // This library is free software; you can redistribute it and/or 00137 // modify it under the terms of the GNU Lesser General Public 00138 // License as published by the Free Software Foundation; either 00139 // version 2.1 of the License, or any later version. 00140 // 00141 // This library is distributed in the hope that it will be useful, 00142 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00143 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00144 // Lesser General Public License for more details. 00145 00146 // You should have received a copy of the GNU Lesser General Public 00147 // License along with this library; if not, write to the Free Software 00148 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 00149