PLearn 0.1
Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | Static Protected Member Functions | Protected Attributes | Private Types | Private Member Functions
PLearn::RBMParameters Class Reference

Virtual class for the parameters between two layers of an RBM. More...

#include <RBMParameters.h>

Inheritance diagram for PLearn::RBMParameters:
Inheritance graph
[legend]
Collaboration diagram for PLearn::RBMParameters:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 RBMParameters (real the_learning_rate=0.)
 Default constructor.
 RBMParameters (string down_types, string up_types, real the_learning_rate=0.)
 Constructor from two string prototypes.
virtual void setAsUpInput (const Vec &input) const
 Sets input_vec to input, and going_up to false.
virtual void setAsDownInput (const Vec &input) const
 Sets input_vec to input, and going_up to true.
virtual void accumulatePosStats (const Vec &down_values, const Vec &up_values)=0
 Accumulates positive phase statistics to *_pos_stats.
virtual void accumulateNegStats (const Vec &down_values, const Vec &up_values)=0
 Accumulates negative phase statistics to *_neg_stats.
virtual void update ()=0
 Updates parameters according to contrastive divergence gradient.
virtual void update (const Vec &pos_down_values, const Vec &pos_up_values, const Vec &neg_down_values, const Vec &neg_up_values)
 Updates parameters according to contrastive divergence gradient, not using the statistics but the explicit values passed.
virtual void clearStats ()=0
 Clear all information accumulated during stats.
virtual void computeUnitActivations (int start, int length, const Vec &activations) const =0
 Computes the vectors of activation of "length" units, starting from "start", and concatenates them into "activations".
virtual void fprop (const Vec &input, Vec &output) const
 given the input, compute the output (possibly resize it appropriately)
virtual int nParameters (bool share_up_params, bool share_down_params) const =0
 return the number of parameters
virtual Vec makeParametersPointHere (const Vec &global_parameters, bool share_up_params, bool share_down_params)=0
 Make the parameters data be sub-vectors of the given global_parameters.
virtual RBMParametersdeepCopy (CopiesMap &copies) const
virtual void build ()
 Post-constructor.
virtual void makeDeepCopyFromShallowCopy (CopiesMap &copies)
 Transforms a shallow copy into a deep copy.

Static Public Member Functions

static string _classname_ ()
static OptionList_getOptionList_ ()
static RemoteMethodMap_getRemoteMethodMap_ ()
static bool _isa_ (const Object *o)
static void _static_initialize_ ()
static const PPathdeclaringFile ()

Public Attributes

string up_units_types
 Each character of this string describes the type of an up unit:
string down_units_types
 Same meaning as "up_units_types", but with down units.
real learning_rate
 The learning rate, used both in update() and bpropUpdate() methods.
string initialization_method
 The method used to initialize the weights:
int up_layer_size
 Number of units on up layer.
int down_layer_size
 Number of units on down layer.

Static Public Attributes

static StaticInitializer _static_initializer_

Static Protected Member Functions

static void declareOptions (OptionList &ol)
 Declares the class options.

Protected Attributes

Vec input_vec
 Points to current input vector.
bool going_up
 Tells if input_vec comes from down (true) or up (false)
int pos_count
 Number of examples accumulated in *_pos_stats.
int neg_count
 Number of examples accumulated in *_neg_stats.

Private Types

typedef OnlineLearningModule inherited

Private Member Functions

void build_ ()
 This does the actual building.

Detailed Description

Virtual class for the parameters between two layers of an RBM.

Todo:
: yes
Deprecated:
Use ../RBMConnection.h instead

Definition at line 58 of file RBMParameters.h.


Member Typedef Documentation


Constructor & Destructor Documentation

PLearn::RBMParameters::RBMParameters ( real  the_learning_rate = 0.)

Default constructor.

Definition at line 54 of file RBMParameters.cc.

                                                     :
    learning_rate(the_learning_rate),
    going_up(true),
    pos_count(0),
    neg_count(0)
{
}
PLearn::RBMParameters::RBMParameters ( string  down_types,
string  up_types,
real  the_learning_rate = 0. 
)

Constructor from two string prototypes.

Definition at line 62 of file RBMParameters.cc.

References build().

                                                       :
    up_units_types(up_types),
    down_units_types(down_types),
    learning_rate(the_learning_rate),
    going_up(true),
    pos_count(0),
    neg_count(0)
{
    // We're not sure inherited::build() has been called
    build();
}

Here is the call graph for this function:


Member Function Documentation

string PLearn::RBMParameters::_classname_ ( ) [static]
OptionList & PLearn::RBMParameters::_getOptionList_ ( ) [static]
RemoteMethodMap & PLearn::RBMParameters::_getRemoteMethodMap_ ( ) [static]
bool PLearn::RBMParameters::_isa_ ( const Object o) [static]
StaticInitializer RBMParameters::_static_initializer_ & PLearn::RBMParameters::_static_initialize_ ( ) [static]
virtual void PLearn::RBMParameters::accumulateNegStats ( const Vec down_values,
const Vec up_values 
) [pure virtual]

Accumulates negative phase statistics to *_neg_stats.

Implemented in PLearn::RBMConv2DLLParameters, PLearn::RBMGenericParameters, PLearn::RBMLLParameters, PLearn::RBMLQParameters, and PLearn::RBMQLParameters.

Referenced by update().

Here is the caller graph for this function:

virtual void PLearn::RBMParameters::accumulatePosStats ( const Vec down_values,
const Vec up_values 
) [pure virtual]

Accumulates positive phase statistics to *_pos_stats.

Implemented in PLearn::RBMConv2DLLParameters, PLearn::RBMGenericParameters, PLearn::RBMLLParameters, PLearn::RBMLQParameters, and PLearn::RBMQLParameters.

Referenced by update().

Here is the caller graph for this function:

void PLearn::RBMParameters::build ( ) [virtual]

Post-constructor.

The normal implementation should call simply inherited::build(), then this class's build_(). This method should be callable again at later times, after modifying some option fields to change the "architecture" of the object.

Reimplemented from PLearn::OnlineLearningModule.

Reimplemented in PLearn::RBMConv2DLLParameters, PLearn::RBMGenericParameters, PLearn::RBMJointGenericParameters, PLearn::RBMJointLLParameters, PLearn::RBMLLParameters, PLearn::RBMLQParameters, and PLearn::RBMQLParameters.

Definition at line 138 of file RBMParameters.cc.

References PLearn::OnlineLearningModule::build(), and build_().

Referenced by PLearn::RBMQLParameters::build(), PLearn::RBMLQParameters::build(), PLearn::RBMLLParameters::build(), PLearn::RBMGenericParameters::build(), PLearn::RBMConv2DLLParameters::build(), and RBMParameters().

Here is the call graph for this function:

Here is the caller graph for this function:

void PLearn::RBMParameters::build_ ( ) [private]

This does the actual building.

Reimplemented from PLearn::OnlineLearningModule.

Reimplemented in PLearn::RBMConv2DLLParameters, PLearn::RBMGenericParameters, PLearn::RBMJointGenericParameters, PLearn::RBMJointLLParameters, PLearn::RBMLLParameters, PLearn::RBMLQParameters, and PLearn::RBMQLParameters.

Definition at line 116 of file RBMParameters.cc.

References down_layer_size, down_units_types, initialization_method, PLearn::OnlineLearningModule::input_size, PLearn::lowerstring(), PLearn::OnlineLearningModule::output_size, PLERROR, up_layer_size, and up_units_types.

Referenced by build().

{
    up_layer_size = int(up_units_types.size());
    down_layer_size = int(down_units_types.size());
    if( up_layer_size == 0 || down_layer_size == 0 )
        return;

    string im = lowerstring( initialization_method );
    if( im == "" || im == "uniform_sqrt" )
        initialization_method = "uniform_sqrt";
    else if( im == "uniform_linear" )
        initialization_method = im;
    else if( im == "zero" )
        initialization_method = im;
    else
        PLERROR( "RBMParameters::build_ - initialization_method\n"
                 "\"%s\" unknown.\n", initialization_method.c_str() );

    input_size = down_layer_size;
    output_size = up_layer_size;
}

Here is the call graph for this function:

Here is the caller graph for this function:

virtual void PLearn::RBMParameters::clearStats ( ) [pure virtual]
virtual void PLearn::RBMParameters::computeUnitActivations ( int  start,
int  length,
const Vec activations 
) const [pure virtual]

Computes the vectors of activation of "length" units, starting from "start", and concatenates them into "activations".

"start" indexes an up unit if "going_up", else a down unit.

Implemented in PLearn::RBMConv2DLLParameters, PLearn::RBMGenericParameters, PLearn::RBMJointGenericParameters, PLearn::RBMJointLLParameters, PLearn::RBMLLParameters, PLearn::RBMLQParameters, and PLearn::RBMQLParameters.

Referenced by fprop().

Here is the caller graph for this function:

void PLearn::RBMParameters::declareOptions ( OptionList ol) [static, protected]

Declares the class options.

Reimplemented from PLearn::OnlineLearningModule.

Reimplemented in PLearn::RBMConv2DLLParameters, PLearn::RBMGenericParameters, PLearn::RBMJointGenericParameters, PLearn::RBMJointLLParameters, PLearn::RBMLLParameters, PLearn::RBMLQParameters, and PLearn::RBMQLParameters.

Definition at line 75 of file RBMParameters.cc.

References PLearn::OptionBase::buildoption, PLearn::declareOption(), PLearn::OnlineLearningModule::declareOptions(), down_units_types, initialization_method, learning_rate, and up_units_types.

Referenced by PLearn::RBMQLParameters::declareOptions(), PLearn::RBMLQParameters::declareOptions(), PLearn::RBMLLParameters::declareOptions(), PLearn::RBMGenericParameters::declareOptions(), and PLearn::RBMConv2DLLParameters::declareOptions().

{
    // ### Declare all of this object's options here.
    // ### For the "flags" of each option, you should typically specify
    // ### one of OptionBase::buildoption, OptionBase::learntoption or
    // ### OptionBase::tuningoption. If you don't provide one of these three,
    // ### this option will be ignored when loading values from a script.
    // ### You can also combine flags, for example with OptionBase::nosave:
    // ### (OptionBase::buildoption | OptionBase::nosave)

    declareOption(ol, "up_units_types", &RBMParameters::up_units_types,
                  OptionBase::buildoption,
                  "Each character of this string describes the type of an"
                  " up unit:\n"
                  "  - 'l' if the energy function of this unit is linear\n"
                  "    (binomial or multinomial unit),\n"
                  "  - 'q' if it is quadratic (for a gaussian unit).\n");

    declareOption(ol, "down_units_types", &RBMParameters::down_units_types,
                  OptionBase::buildoption,
                  "Same meaning as 'up_units_types', but with down units");

    declareOption(ol, "learning_rate", &RBMParameters::learning_rate,
                  OptionBase::buildoption,
                  "The learning rate, used both in update() and bpropUpdate() "
                  "methods\n");

    declareOption(ol, "initialization_method",
                  &RBMParameters::initialization_method,
                  OptionBase::buildoption,
                  "The method used to initialize the weights:\n"
                  "  - \"uniform_linear\" = a uniform law in [-1/d, 1/d]\n"
                  "  - \"uniform_sqrt\"   = a uniform law in [-1/sqrt(d),"
                  " 1/sqrt(d)]\n"
                  "  - \"zero\"           = all weights are set to 0,\n"
                  "where d = max( up_layer_size, down_layer_size ).\n");

    // Now call the parent class' declareOptions
    inherited::declareOptions(ol);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static const PPath& PLearn::RBMParameters::declaringFile ( ) [inline, static]

Reimplemented from PLearn::OnlineLearningModule.

Reimplemented in PLearn::RBMConv2DLLParameters, PLearn::RBMGenericParameters, PLearn::RBMJointGenericParameters, PLearn::RBMJointLLParameters, PLearn::RBMLLParameters, PLearn::RBMLQParameters, and PLearn::RBMQLParameters.

Definition at line 155 of file RBMParameters.h.

:
    //#####  Not Options  #####################################################
RBMParameters * PLearn::RBMParameters::deepCopy ( CopiesMap copies) const [virtual]
void PLearn::RBMParameters::fprop ( const Vec input,
Vec output 
) const [virtual]

given the input, compute the output (possibly resize it appropriately)

Reimplemented from PLearn::OnlineLearningModule.

Reimplemented in PLearn::RBMJointGenericParameters, and PLearn::RBMJointLLParameters.

Definition at line 182 of file RBMParameters.cc.

References computeUnitActivations(), PLearn::OnlineLearningModule::output_size, PLearn::TVec< T >::resize(), and setAsDownInput().

{
    // propagates the activations.
    setAsDownInput( input );
    output.resize( output_size );
    computeUnitActivations( 0, output_size, output );
}

Here is the call graph for this function:

void PLearn::RBMParameters::makeDeepCopyFromShallowCopy ( CopiesMap copies) [virtual]
virtual Vec PLearn::RBMParameters::makeParametersPointHere ( const Vec global_parameters,
bool  share_up_params,
bool  share_down_params 
) [pure virtual]

Make the parameters data be sub-vectors of the given global_parameters.

The argument should have size >= nParameters. The result is a Vec that starts just after this object's parameters end, i.e. result = global_parameters.subVec(nParameters(),global_parameters.size()-nParameters()); This allows to easily chain calls of this method on multiple RBMParameters.

Implemented in PLearn::RBMConv2DLLParameters, PLearn::RBMGenericParameters, PLearn::RBMLLParameters, PLearn::RBMLQParameters, and PLearn::RBMQLParameters.

virtual int PLearn::RBMParameters::nParameters ( bool  share_up_params,
bool  share_down_params 
) const [pure virtual]
void PLearn::RBMParameters::setAsDownInput ( const Vec input) const [virtual]
void PLearn::RBMParameters::setAsUpInput ( const Vec input) const [virtual]
virtual void PLearn::RBMParameters::update ( ) [pure virtual]

Updates parameters according to contrastive divergence gradient.

Implemented in PLearn::RBMConv2DLLParameters, PLearn::RBMGenericParameters, PLearn::RBMLLParameters, PLearn::RBMLQParameters, and PLearn::RBMQLParameters.

Referenced by update().

Here is the caller graph for this function:

void PLearn::RBMParameters::update ( const Vec pos_down_values,
const Vec pos_up_values,
const Vec neg_down_values,
const Vec neg_up_values 
) [virtual]

Updates parameters according to contrastive divergence gradient, not using the statistics but the explicit values passed.

Reimplemented in PLearn::RBMConv2DLLParameters, and PLearn::RBMLLParameters.

Definition at line 170 of file RBMParameters.cc.

References accumulateNegStats(), accumulatePosStats(), and update().

{
    // Not-so-efficient implementation
    accumulatePosStats( pos_down_values, pos_up_values );
    accumulateNegStats( neg_down_values, neg_up_values );
    update();
}

Here is the call graph for this function:


Member Data Documentation

bool PLearn::RBMParameters::going_up [mutable, protected]

Tells if input_vec comes from down (true) or up (false)

Definition at line 170 of file RBMParameters.h.

Referenced by PLearn::RBMJointLLParameters::setAsCondInput(), PLearn::RBMJointGenericParameters::setAsCondInput(), setAsDownInput(), and setAsUpInput().

The method used to initialize the weights:

  • "uniform_linear" = a uniform law in [-1/d, 1/d]
  • "uniform_sqrt" = a uniform law in [-1/sqrt(d), 1/sqrt(d)]
  • "zero" = all weights are set to 0 Where d = max( up_layer_size, down_layer_size )

Definition at line 82 of file RBMParameters.h.

Referenced by build_(), declareOptions(), PLearn::RBMQLParameters::forget(), PLearn::RBMLLParameters::forget(), PLearn::RBMLQParameters::forget(), PLearn::RBMGenericParameters::forget(), and PLearn::RBMConv2DLLParameters::forget().

Vec PLearn::RBMParameters::input_vec [mutable, protected]

The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines