PLearn 0.1
|
00001 // -*- C++ -*- 00002 00003 // RBMGenericParameters.h 00004 // 00005 // Copyright (C) 2006 Pascal Lamblin 00006 // 00007 // Redistribution and use in source and binary forms, with or without 00008 // modification, are permitted provided that the following conditions are met: 00009 // 00010 // 1. Redistributions of source code must retain the above copyright 00011 // notice, this list of conditions and the following disclaimer. 00012 // 00013 // 2. Redistributions in binary form must reproduce the above copyright 00014 // notice, this list of conditions and the following disclaimer in the 00015 // documentation and/or other materials provided with the distribution. 00016 // 00017 // 3. The name of the authors may not be used to endorse or promote 00018 // products derived from this software without specific prior written 00019 // permission. 00020 // 00021 // THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR 00022 // IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 00023 // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN 00024 // NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 00025 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 00026 // TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 00027 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 00028 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 00029 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 00030 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00031 // 00032 // This file is part of the PLearn library. For more information on the PLearn 00033 // library, go to the PLearn Web site at www.plearn.org 00034 00035 // Authors: Pascal Lamblin 00036 00040 #ifndef RBMGenericParameters_INC 00041 #define RBMGenericParameters_INC 00042 00043 #include "RBMParameters.h" 00044 00045 namespace PLearn { 00046 using namespace std; 00047 00048 //class RBMLayer; 00049 00056 class RBMGenericParameters: public RBMParameters 00057 { 00058 typedef RBMParameters inherited; 00059 00060 public: 00061 //##### Public Build Options ############################################ 00062 00063 //##### Learned Options ################################################# 00064 00066 Mat weights; 00067 00069 TVec<Vec> up_units_params; 00070 00072 TVec<Vec> down_units_params; 00073 00074 //##### Not Options ##################################################### 00075 00077 Mat weights_pos_stats; 00078 00080 Mat weights_neg_stats; 00081 00083 TVec<Vec> up_units_params_pos_stats; 00085 TVec<Vec> up_units_params_neg_stats; 00087 TVec<Vec> down_units_params_pos_stats; 00089 TVec<Vec> down_units_params_neg_stats; 00090 00091 public: 00092 //##### Public Member Functions ######################################### 00093 00095 RBMGenericParameters( real the_learning_rate=0 ); 00096 00098 RBMGenericParameters( string down_types, string up_types, 00099 real the_learning_rate=0 ); 00100 00101 /* 00103 RBMGenericParameters( PP<RBMLayer> down, PP<RBMLayer> up, 00104 real the_learning_rate=0 ); 00105 // */ 00106 00107 // Your other public member functions go here 00108 00110 virtual void accumulatePosStats( const Vec& down_values, 00111 const Vec& up_values ); 00112 00114 virtual void accumulateNegStats( const Vec& down_values, 00115 const Vec& up_values ); 00116 00118 virtual void update(); 00119 00121 virtual void clearStats(); 00122 00126 virtual void computeUnitActivations( int start, int length, 00127 const Vec& activations ) const; 00128 00139 // virtual void bpropUpdate(const Vec& input, const Vec& output, 00140 // const Vec& output_gradient); 00141 00144 virtual void bpropUpdate(const Vec& input, const Vec& output, 00145 Vec& input_gradient, 00146 const Vec& output_gradient); 00147 00151 virtual void forget(); 00152 00157 // virtual void finalize(); 00158 00161 virtual int nParameters(bool share_up_params, bool share_down_params) const; 00162 00169 virtual Vec makeParametersPointHere(const Vec& global_parameters, bool share_up_params, bool share_down_params); 00170 00171 //##### PLearn::Object Protocol ######################################### 00172 00173 // Declares other standard object methods. 00174 PLEARN_DECLARE_OBJECT(RBMGenericParameters); 00175 00176 // Simply calls inherited::build() then build_() 00177 virtual void build(); 00178 00180 virtual void makeDeepCopyFromShallowCopy(CopiesMap& copies); 00181 00182 protected: 00183 00184 protected: 00185 //##### Protected Member Functions ###################################### 00188 virtual void computeLinearUnitActivations( int i, const Vec& activations ) 00189 const; 00190 00193 virtual void computeQuadraticUnitActivations( int i, 00194 const Vec& activations ) 00195 const; 00196 00197 00199 static void declareOptions(OptionList& ol); 00200 00201 private: 00202 //##### Private Member Functions ######################################## 00203 00205 void build_(); 00206 00207 private: 00208 //##### Private Data Members ############################################ 00209 00210 // The rest of the private stuff goes here 00211 }; 00212 00213 // Declares a few other classes and functions related to this class 00214 DECLARE_OBJECT_PTR(RBMGenericParameters); 00215 00216 } // end of namespace PLearn 00217 00218 #endif 00219 00220 00221 /* 00222 Local Variables: 00223 mode:c++ 00224 c-basic-offset:4 00225 c-file-style:"stroustrup" 00226 c-file-offsets:((innamespace . 0)(inline-open . 0)) 00227 indent-tabs-mode:nil 00228 fill-column:79 00229 End: 00230 */ 00231 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=79 :