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