00001 /****************************************************************************************************************/ 00002 /* */ 00003 /* OpenNN: Open Neural Networks Library */ 00004 /* www.opennn.cimne.com */ 00005 /* */ 00006 /* P R O B A B I L I S T I C L A Y E 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 __PROBABILISTICLAYER_H__ 00017 #define __PROBABILISTICLAYER_H__ 00018 00019 // System includes 00020 00021 #include <string> 00022 00023 // OpenNN includes 00024 00025 #include "../utilities/vector.h" 00026 #include "../utilities/matrix.h" 00027 00028 // TinyXml includes 00029 00030 #include "../../parsers/tinyxml/tinyxml.h" 00031 00032 namespace OpenNN 00033 { 00034 00038 00039 class ProbabilisticLayer 00040 { 00041 00042 public: 00043 00044 // DEFAULT CONSTRUCTOR 00045 00046 explicit ProbabilisticLayer(void); 00047 00048 // PROBABILISTIC NEURONS NUMBER CONSTRUCTOR 00049 00050 explicit ProbabilisticLayer(const unsigned int&); 00051 00052 // COPY CONSTRUCTOR 00053 00054 ProbabilisticLayer(const ProbabilisticLayer&); 00055 00056 // DESTRUCTOR 00057 00058 virtual ~ProbabilisticLayer(void); 00059 00060 // ASSIGNMENT OPERATOR 00061 00062 ProbabilisticLayer& operator = (const ProbabilisticLayer&); 00063 00064 // EQUAL TO OPERATOR 00065 00066 bool operator == (const ProbabilisticLayer&) const; 00067 00068 // ENUMERATIONS 00069 00071 00072 enum ProbabilisticMethod{Competitive, Softmax}; 00073 00074 // GET METHODS 00075 00076 const unsigned int& get_probabilistic_neurons_number(void) const; 00077 00078 // Probabilistic processing 00079 00080 const ProbabilisticMethod& get_probabilistic_method(void) const; 00081 std::string write_probabilistic_method(void) const; 00082 00083 // Display messages 00084 00085 const bool& get_display(void) const; 00086 00087 // SET METHODS 00088 00089 void set(void); 00090 void set(const unsigned int&); 00091 void set(const ProbabilisticLayer&); 00092 00093 void set_probabilistic_neurons_number(const unsigned int&); 00094 00095 void set_probabilistic_method(const ProbabilisticMethod&); 00096 void set_probabilistic_method(const std::string&); 00097 00098 virtual void set_default(void); 00099 00100 // Display messages 00101 00102 void set_display(const bool&); 00103 00104 00105 void initialize_random(void); 00106 00107 // Probabilistic post-processing 00108 00109 Vector<double> calculate_outputs(const Vector<double>&) const; 00110 Matrix<double> calculate_Jacobian(const Vector<double>&) const; 00111 Vector< Matrix<double> > calculate_Hessian_form(const Vector<double>&) const; 00112 00113 Vector<double> calculate_competitive_output(const Vector<double>&) const; 00114 Matrix<double> calculate_competitive_Jacobian(const Vector<double>&) const; 00115 Vector< Matrix<double> > calculate_competitive_Hessian_form(const Vector<double>&) const; 00116 00117 Vector<double> calculate_softmax_output(const Vector<double>&) const; 00118 Matrix<double> calculate_softmax_Jacobian(const Vector<double>&) const; 00119 Vector< Matrix<double> > calculate_softmax_Hessian_form(const Vector<double>&) const; 00120 00121 // Expression methods 00122 00123 std::string write_competitive_expression(const Vector<std::string>&, const Vector<std::string>&) const; 00124 std::string write_softmax_expression(const Vector<std::string>&, const Vector<std::string>&) const; 00125 00126 std::string write_expression(const Vector<std::string>&, const Vector<std::string>&) const; 00127 00128 // Serialization methods 00129 00130 std::string to_string(void) const; 00131 00132 virtual TiXmlElement* to_XML(void) const; 00133 virtual void from_XML(TiXmlElement*); 00134 00135 protected: 00136 00137 // MEMBERS 00138 00140 00141 unsigned int probabilistic_neurons_number; 00142 00144 00145 ProbabilisticMethod probabilistic_method; 00146 00148 00149 bool display; 00150 }; 00151 00152 } 00153 00154 #endif 00155 00156 00157 // OpenNN: Open Neural Networks Library. 00158 // Copyright (C) 2005-2012 Roberto Lopez 00159 // 00160 // This library is free software; you can redistribute it and/or 00161 // modify it under the terms of the GNU Lesser General Public 00162 // License as published by the Free Software Foundation; either 00163 // version 2.1 of the License, or any later version. 00164 // 00165 // This library is distributed in the hope that it will be useful, 00166 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00167 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00168 // Lesser General Public License for more details. 00169 00170 // You should have received a copy of the GNU Lesser General Public 00171 // License along with this library; if not, write to the Free Software 00172 00173 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 00174