PLearn 0.1
PvGradNNet.h
Go to the documentation of this file.
00001 // -*- C++ -*-
00002 // PvGradNNet.h
00003 //
00004 // Copyright (C) 2007 PA M
00005 //
00006 // Redistribution and use in source and binary forms, with or without
00007 // modification, are permitted provided that the following conditions are met:
00008 //
00009 //  1. Redistributions of source code must retain the above copyright
00010 //     notice, this list of conditions and the following disclaimer.
00011 //
00012 //  2. Redistributions in binary form must reproduce the above copyright
00013 //     notice, this list of conditions and the following disclaimer in the
00014 //     documentation and/or other materials provided with the distribution.
00015 //
00016 //  3. The name of the authors may not be used to endorse or promote
00017 //     products derived from this software without specific prior written
00018 //     permission.
00019 //
00020 // THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR
00021 // IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
00022 // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
00023 // NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
00024 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
00025 // TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
00026 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
00027 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
00028 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00029 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00030 //
00031 // This file is part of the PLearn library. For more information on the PLearn
00032 // library, go to the PLearn Web site at www.plearn.org
00033 
00034 // Authors: PA M
00035 
00039 #ifndef PvGradNNet_INC
00040 #define PvGradNNet_INC
00041 
00042 #include <plearn_learners/generic/EXPERIMENTAL/mNNet.h>
00043 
00044 namespace PLearn {
00045 
00049 class PvGradNNet : public mNNet
00050 {
00051     typedef mNNet inherited;
00052 
00053 public:
00054     //#####  Public Build Options  ############################################
00055 
00057     real pv_initial_stepsize;
00058 
00060     real pv_min_stepsize, pv_max_stepsize;
00061 
00063     real pv_acceleration, pv_deceleration;
00064 
00066     int pv_min_samples;
00067 
00070     real pv_required_confidence;
00071     real pv_conf_ct;
00072 
00073     int pv_strategy;
00074 
00076     // each parameter based on the estimated probability of it being positive
00077     // or negative.
00078     bool pv_random_sample_step;
00079 
00082     real pv_self_discount, pv_other_discount, pv_within_neuron_discount;
00083 
00084 public:
00085     //#####  Public Not Build Options  ########################################
00086 
00087 public:
00088     //#####  Public Member Functions  #########################################
00089 
00090     PvGradNNet();
00091 
00092     //#####  PLearner Member Functions  #######################################
00093 
00097     virtual void forget();
00098 
00099     //#####  PLearn::Object Protocol  #########################################
00100 
00101     // Declares other standard object methods.
00102     // ### If your class is not instantiatable (it has pure virtual methods)
00103     // ### you should replace this by PLEARN_DECLARE_ABSTRACT_OBJECT_METHODS
00104     PLEARN_DECLARE_OBJECT(PvGradNNet);
00105 
00106     // Simply calls inherited::build() then build_()
00107     virtual void build();
00108 
00110     virtual void makeDeepCopyFromShallowCopy(CopiesMap& copies);
00111 
00112 protected:
00113     //#####  Protected Options  ###############################################
00114     // ### Declare protected option fields (such as learned parameters) here
00115 
00116 protected:
00117     //#####  Protected Member Functions  ######################################
00118 
00120     static void declareOptions(OptionList& ol);
00121 
00122     virtual void bpropUpdateNet(const int t);
00123 
00124     void pvGrad(); 
00125     void discountGrad();
00126     void neuronDiscountGrad();
00127     void globalSyncGrad();
00128     void neuronSyncGrad();
00129     
00130 private:
00131     //#####  Private Member Functions  ########################################
00132 
00134     void build_();
00135 
00136 private:
00137     //#####  Private Data Members  ############################################
00138 
00140     Vec pv_all_nsamples;
00141     TVec< Mat > pv_layer_nsamples;
00143     Vec pv_all_sum;
00144     TVec<Mat> pv_layer_sum;
00146     Vec pv_all_sumsquare;
00147     TVec<Mat> pv_layer_sumsquare;
00148 
00150     TVec<int> pv_all_stepsigns;
00151     TVec< TMat<int> > pv_layer_stepsigns;
00152 
00154     Vec pv_all_stepsizes;
00155     TVec<Mat> pv_layer_stepsizes;
00156 
00158     // int is enough?
00159     int n_updates;
00160 
00161     TVec<int> n_neuron_updates;
00162 
00164     //PP<VecStatsCollector> pv_gradstats;
00165 
00166     real limit_ratio;
00167     real n_small_ratios;
00168 };
00169 
00170 // Declares a few other classes and functions related to this class
00171 DECLARE_OBJECT_PTR(PvGradNNet);
00172 
00173 } // end of namespace PLearn
00174 
00175 #endif
00176 
00177 
00178 /*
00179   Local Variables:
00180   mode:c++
00181   c-basic-offset:4
00182   c-file-style:"stroustrup"
00183   c-file-offsets:((innamespace . 0)(inline-open . 0))
00184   indent-tabs-mode:nil
00185   fill-column:79
00186   End:
00187 */
00188 // 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