PLearn 0.1
RBMMatrixTransposeConnection.h
Go to the documentation of this file.
00001 // -*- C++ -*-
00002 
00003 // RBMMatrixTransposeConnection.h
00004 //
00005 // Copyright (C) 2007 Hugo Larochelle
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: Hugo Larochelle
00036 
00040 #ifndef RBMMatrixTransposeConnection_INC
00041 #define RBMMatrixTransposeConnection_INC
00042 
00043 #include <plearn_learners/online/RBMConnection.h>
00044 #include <plearn_learners/online/RBMMatrixConnection.h>
00045 
00046 namespace PLearn {
00047 using namespace std;
00048 
00049 
00053 class RBMMatrixTransposeConnection: public RBMConnection
00054 {
00055     typedef RBMConnection inherited;
00056 
00057 public:
00058     //#####  Public Build Options  ############################################
00059 
00060     //#####  Learned Options  #################################################
00061 
00063     Mat weights;
00064 
00066     PP<RBMMatrixConnection> rbm_matrix_connection;
00067 
00069     bool learn_scale;
00070 
00071     //#####  Not Options  #####################################################
00072 
00074     real scale;
00075 
00077     Mat weights_pos_stats;
00078 
00080     Mat weights_neg_stats;
00081 
00083     Mat weights_inc;
00084 
00085 public:
00086     //#####  Public Member Functions  #########################################
00087 
00089     RBMMatrixTransposeConnection(
00090         PP<RBMMatrixConnection> the_rbm_matrix_connection = 0,
00091         real the_learning_rate = 0,
00092         bool call_build_ = false);
00093 
00094     // Your other public member functions go here
00095 
00097     virtual void accumulatePosStats( const Vec& down_values,
00098                                      const Vec& up_values );
00099 
00100     virtual void accumulatePosStats( const Mat& down_values,
00101                                      const Mat& up_values )
00102     {
00103         PLASSERT_MSG( false, "Not implemented" );
00104     }
00105 
00107     virtual void accumulateNegStats( const Vec& down_values,
00108                                      const Vec& up_values );
00109 
00110     virtual void accumulateNegStats( const Mat& down_values,
00111                                      const Mat& up_values )
00112     {
00113         PLASSERT_MSG( false, "Not implemented" );
00114     }
00115 
00117     virtual void update();
00118 
00121     virtual void update( const Vec& pos_down_values,
00122                          const Vec& pos_up_values,
00123                          const Vec& neg_down_values,
00124                          const Vec& neg_up_values );
00125 
00127     virtual void clearStats();
00128 
00132     virtual void computeProduct( int start, int length,
00133                                  const Vec& activations,
00134                                  bool accumulate=false ) const;
00135 
00137     virtual void computeProducts(int start, int length,
00138                                  Mat& activations,
00139                                  bool accumulate=false ) const;
00140 
00151     // virtual void bpropUpdate(const Vec& input, const Vec& output,
00152     //                          const Vec& output_gradient);
00153 
00156     virtual void bpropUpdate(const Vec& input, const Vec& output,
00157                              Vec& input_gradient,
00158                              const Vec& output_gradient,
00159                              bool accumulate=false);
00160 
00161     virtual void bpropUpdate(const Mat& inputs, const Mat& outputs,
00162                              Mat& input_gradients,
00163                              const Mat& output_gradients,
00164                              bool accumulate = false);
00165 
00169     virtual void forget();
00170 
00175     // virtual void finalize();
00176 
00178     virtual int nParameters() const;
00179 
00185     virtual Vec makeParametersPointHere(const Vec& global_parameters);
00186 
00187     //#####  PLearn::Object Protocol  #########################################
00188 
00189     // Declares other standard object methods.
00190     PLEARN_DECLARE_OBJECT(RBMMatrixTransposeConnection);
00191 
00192     // Simply calls inherited::build() then build_()
00193     virtual void build();
00194 
00196     virtual void makeDeepCopyFromShallowCopy(CopiesMap& copies);
00197 
00198 protected:
00199     //#####  Protected Member Functions  ######################################
00201     static void declareOptions(OptionList& ol);
00202 
00203 private:
00204     //#####  Private Member Functions  ########################################
00205 
00207     void build_();
00208 
00209 private:
00210     //#####  Private Data Members  ############################################
00211 
00212     // The rest of the private stuff goes here
00213 };
00214 
00215 // Declares a few other classes and functions related to this class
00216 DECLARE_OBJECT_PTR(RBMMatrixTransposeConnection);
00217 
00218 } // end of namespace PLearn
00219 
00220 #endif
00221 
00222 
00223 /*
00224   Local Variables:
00225   mode:c++
00226   c-basic-offset:4
00227   c-file-style:"stroustrup"
00228   c-file-offsets:((innamespace . 0)(inline-open . 0))
00229   indent-tabs-mode:nil
00230   fill-column:79
00231   End:
00232 */
00233 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=79 :
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines