PLearn 0.1
|
00001 // -*- C++ -*- 00002 00003 // RBMConv2DLLParameters.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 RBMConv2DLLParameters_INC 00041 #define RBMConv2DLLParameters_INC 00042 00043 #include "RBMParameters.h" 00044 00045 namespace PLearn { 00046 using namespace std; 00047 00048 00055 class RBMConv2DLLParameters: public RBMParameters 00056 { 00057 typedef RBMParameters inherited; 00058 00059 public: 00060 //##### Public Build Options ############################################ 00061 00063 real momentum; 00064 00066 int down_image_length; 00067 00069 int down_image_width; 00070 00072 int up_image_length; 00073 00075 int up_image_width; 00076 00078 int kernel_step1; 00079 00081 int kernel_step2; 00082 00083 //##### Learned Options ################################################# 00084 00086 Mat kernel; 00087 00089 Vec up_units_bias; 00090 00092 Vec down_units_bias; 00093 00094 //##### Not Options ##################################################### 00095 00097 int kernel_length; 00098 00100 int kernel_width; 00101 00103 Mat kernel_pos_stats; 00104 00106 Mat kernel_neg_stats; 00107 00109 Vec up_units_bias_pos_stats; 00111 Vec up_units_bias_neg_stats; 00113 Vec down_units_bias_pos_stats; 00115 Vec down_units_bias_neg_stats; 00116 00118 Mat kernel_inc; 00119 Vec down_units_bias_inc; 00120 Vec up_units_bias_inc; 00121 00122 public: 00123 //##### Public Member Functions ######################################### 00124 00126 RBMConv2DLLParameters( real the_learning_rate=0 ); 00127 00129 RBMConv2DLLParameters( string down_types, string up_types, 00130 real the_learning_rate=0 ); 00131 00132 // Your other public member functions go here 00133 00135 virtual void accumulatePosStats( const Vec& down_values, 00136 const Vec& up_values ); 00137 00139 virtual void accumulateNegStats( const Vec& down_values, 00140 const Vec& up_values ); 00141 00143 virtual void update(); 00144 00147 virtual void update( const Vec& pos_down_values, 00148 const Vec& pos_up_values, 00149 const Vec& neg_down_values, 00150 const Vec& neg_up_values ); 00151 00153 virtual void clearStats(); 00154 00158 virtual void computeUnitActivations( int start, int length, 00159 const Vec& activations ) const; 00160 00171 // virtual void bpropUpdate(const Vec& input, const Vec& output, 00172 // const Vec& output_gradient); 00173 00176 virtual void bpropUpdate(const Vec& input, const Vec& output, 00177 Vec& input_gradient, 00178 const Vec& output_gradient); 00179 00183 virtual void forget(); 00184 00189 // virtual void finalize(); 00190 00192 virtual int nParameters(bool share_up_params, bool share_down_params) const; 00193 00199 virtual Vec makeParametersPointHere(const Vec& global_parameters, bool share_up_params, bool share_down_params); 00200 00201 //##### PLearn::Object Protocol ######################################### 00202 00203 // Declares other standard object methods. 00204 PLEARN_DECLARE_OBJECT(RBMConv2DLLParameters); 00205 00206 // Simply calls inherited::build() then build_() 00207 virtual void build(); 00208 00210 virtual void makeDeepCopyFromShallowCopy(CopiesMap& copies); 00211 00212 00213 protected: 00214 //##### Protected Member Functions ###################################### 00216 static void declareOptions(OptionList& ol); 00217 00218 private: 00219 //##### Private Member Functions ######################################## 00220 00222 void build_(); 00223 00224 private: 00225 //##### Private Data Members ############################################ 00226 00227 // The rest of the private stuff goes here 00228 mutable Mat down_image; 00229 mutable Mat up_image; 00230 mutable Mat down_image_gradient; 00231 mutable Mat up_image_gradient; 00232 Mat kernel_gradient; 00233 }; 00234 00235 // Declares a few other classes and functions related to this class 00236 DECLARE_OBJECT_PTR(RBMConv2DLLParameters); 00237 00238 } // end of namespace PLearn 00239 00240 #endif 00241 00242 00243 /* 00244 Local Variables: 00245 mode:c++ 00246 c-basic-offset:4 00247 c-file-style:"stroustrup" 00248 c-file-offsets:((innamespace . 0)(inline-open . 0)) 00249 indent-tabs-mode:nil 00250 fill-column:79 00251 End: 00252 */ 00253 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=79 :