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::RBMConnection Class Reference

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

#include <RBMConnection.h>

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

List of all members.

Public Member Functions

 RBMConnection (real the_learning_rate=0, bool call_build_=false)
 Default constructor.
virtual void setLearningRate (real the_learning_rate)
 Sets the learning rate.
virtual void setMomentum (real the_momentum)
 Sets the momentum.
virtual void setAsUpInput (const Vec &input) const
 Sets 'input_vec' to 'input', and 'going_up' to false.
virtual void setAsUpInputs (const Mat &inputs) const
 Set 'inputs_mat' to 'inputs', and 'going_up' to false.
virtual void setAsDownInput (const Vec &input) const
 Sets 'input_vec' to 'input', and 'going_up' to true.
virtual void setAsDownInputs (const Mat &inputs) const
 Set 'inputs_mat' to 'inputs', 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 accumulatePosStats (const Mat &down_values, const Mat &up_values)=0
virtual void accumulateNegStats (const Vec &down_values, const Vec &up_values)=0
 Accumulates negative phase statistics to *_neg_stats.
virtual void accumulateNegStats (const Mat &down_values, const Mat &up_values)=0
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 update (const Mat &pos_down_values, const Mat &pos_up_values, const Mat &neg_down_values, const Mat &neg_up_values)
 Updates parameters according to contrastive divergence gradient, not using the statistics but explicit matrix values.
virtual void updateCDandGibbs (const Mat &pos_down_values, const Mat &pos_up_values, const Mat &cd_neg_down_values, const Mat &cd_neg_up_values, const Mat &gibbs_neg_down_values, const Mat &gibbs_neg_up_values, real background_gibbs_update_ratio)
virtual void updateGibbs (const Mat &pos_down_values, const Mat &pos_up_values, const Mat &gibbs_neg_down_values, const Mat &gibbs_neg_up_values)
virtual void clearStats ()=0
 Clear all information accumulated during stats.
virtual void computeProduct (int start, int length, const Vec &activations, bool accumulate=false) const =0
 Computes the vectors of activation of "length" units, starting from "start", and stores (or add) them into "activations".
virtual void computeProducts (int start, int length, Mat &activations, bool accumulate=false) const =0
 Same as 'computeProduct' but for mini-batches.
virtual void fprop (const Vec &input, Vec &output) const
 given the input, compute the output (possibly resize it appropriately)
virtual void fprop (const Mat &inputs, Mat &outputs)
 Mini-batch fprop.
virtual void getAllWeights (Mat &rbm_weights) const
 provide the internal weight values (not a copy)
virtual void setAllWeights (const Mat &rbm_weights)
 set the internal weight values to rbm_weights (not a copy)
virtual void petiteCulotteOlivierUpdate (const Vec &input, const Mat &rbm_weights, const Vec &output, Vec &input_gradient, Mat &rbm_weights_gradient, const Vec &output_gradient, bool accumulate=false)
 back-propagates the output gradient to the input and the weights (the weights are not updated)
virtual void petiteCulotteOlivierCD (Mat &weights_gradient, bool accumulate=false)
 Computes the contrastive divergence gradient with respect to the weights It should be noted that bpropCD does not call clearstats().
virtual void petiteCulotteOlivierCD (const Vec &pos_down_values, const Vec &pos_up_values, const Vec &neg_down_values, const Vec &neg_up_values, Mat &weights_gradient, bool accumulate=false)
 Computes the contrastive divergence gradient with respect to the weights given the positive and negative phase values.
virtual const TVec< string > & getPorts ()
 Return the list of ports in the module.
virtual const TMat< int > & getPortSizes ()
 Return the size of all ports.
virtual int nParameters () const =0
 return the number of parameters
virtual Vec makeParametersPointHere (const Vec &global_parameters)=0
 Make the parameters data be sub-vectors of the given global_parameters.
virtual RBMConnectiondeepCopy (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

real learning_rate
 The learning rate, used both in update() and bpropUpdate() methods.
real momentum
 Momentum for the gradient descent.
string initialization_method
 The method used to initialize the weights:
int down_size
 Number of units in down layer.
int up_size
 Number of units in up layer.

Static Public Attributes

static StaticInitializer _static_initializer_

Static Protected Member Functions

static void declareOptions (OptionList &ol)
 Declares the class options.
static void declareMethods (RemoteMethodMap &rmm)
 Declares the methods that are remote-callable.

Protected Attributes

Vec input_vec
 Pointer to current input vector.
Mat inputs_mat
 Pointer to current inputs matrix.
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.
TVec< string > ports
 Port names.

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.

Definition at line 56 of file RBMConnection.h.


Member Typedef Documentation


Constructor & Destructor Documentation

PLearn::RBMConnection::RBMConnection ( real  the_learning_rate = 0,
bool  call_build_ = false 
)

Default constructor.

Definition at line 56 of file RBMConnection.cc.

References build_().

                                                                    :
    inherited("", call_build_),
    learning_rate(the_learning_rate),
    momentum(0.),
    down_size(-1),
    up_size(-1),
    going_up(true),
    pos_count(0),
    neg_count(0)
{
    if (call_build_)
        build_();
}

Here is the call graph for this function:


Member Function Documentation

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

Accumulates negative phase statistics to *_neg_stats.

Implemented in PLearn::RBMConv2DConnection, PLearn::RBMDiagonalMatrixConnection, PLearn::RBMMatrixConnection, PLearn::RBMMatrixTransposeConnection, and PLearn::RBMMixedConnection.

Referenced by update().

Here is the caller graph for this function:

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

Accumulates positive phase statistics to *_pos_stats.

Implemented in PLearn::RBMConv2DConnection, PLearn::RBMDiagonalMatrixConnection, PLearn::RBMMatrixConnection, PLearn::RBMMatrixTransposeConnection, and PLearn::RBMMixedConnection.

Referenced by update().

Here is the caller graph for this function:

void PLearn::RBMConnection::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::RBMConv2DConnection, PLearn::RBMDiagonalMatrixConnection, PLearn::RBMMatrixConnection, PLearn::RBMMatrixConnectionNatGrad, PLearn::RBMMatrixTransposeConnection, PLearn::RBMMixedConnection, and PLearn::RBMSparse1DMatrixConnection.

Definition at line 173 of file RBMConnection.cc.

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

Referenced by PLearn::RBMMatrixTransposeConnection::build(), PLearn::RBMMatrixConnection::build(), PLearn::RBMDiagonalMatrixConnection::build(), and PLearn::RBMConv2DConnection::build().

Here is the call graph for this function:

Here is the caller graph for this function:

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

This does the actual building.

Reimplemented from PLearn::OnlineLearningModule.

Reimplemented in PLearn::RBMConv2DConnection, PLearn::RBMDiagonalMatrixConnection, PLearn::RBMMatrixConnection, PLearn::RBMMatrixConnectionNatGrad, PLearn::RBMMatrixTransposeConnection, PLearn::RBMMixedConnection, and PLearn::RBMSparse1DMatrixConnection.

Definition at line 134 of file RBMConnection.cc.

References PLearn::TMat< T >::column(), down_size, PLearn::TMat< T >::fill(), initialization_method, PLearn::OnlineLearningModule::input_size, PLearn::lowerstring(), PLearn::OnlineLearningModule::nPorts(), PLearn::OnlineLearningModule::output_size, PLERROR, PLearn::OnlineLearningModule::port_sizes, ports, PLearn::TMat< T >::resize(), PLearn::TVec< T >::resize(), and up_size.

Referenced by build(), and RBMConnection().

{
    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( "RBMConnection::build_ - initialization_method\n"
                 "\"%s\" unknown.\n", initialization_method.c_str() );

    // for the "OnlineLearningModule" interface
    if( down_size < 0 )
        down_size = input_size;
    else
        input_size = down_size;

    if( up_size < 0 )
        up_size = output_size;
    else
        output_size = up_size;

    ports.resize(2);
    ports[0] = "down";
    ports[1] = "up";
    // NOT weights here, because it only makes sense with an
    // RBMMatrixConnection

    port_sizes.resize(nPorts(), 2);
    port_sizes.column(0).fill(-1);
    port_sizes(0, 1) = down_size;
    port_sizes(1, 1) = up_size;
}

Here is the call graph for this function:

Here is the caller graph for this function:

virtual void PLearn::RBMConnection::clearStats ( ) [pure virtual]
virtual void PLearn::RBMConnection::computeProduct ( int  start,
int  length,
const Vec activations,
bool  accumulate = false 
) const [pure virtual]

Computes the vectors of activation of "length" units, starting from "start", and stores (or add) them into "activations".

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

Implemented in PLearn::RBMConv2DConnection, PLearn::RBMDiagonalMatrixConnection, PLearn::RBMMatrixConnection, PLearn::RBMMatrixTransposeConnection, and PLearn::RBMMixedConnection.

Referenced by fprop().

Here is the caller graph for this function:

virtual void PLearn::RBMConnection::computeProducts ( int  start,
int  length,
Mat activations,
bool  accumulate = false 
) const [pure virtual]

Same as 'computeProduct' but for mini-batches.

Implemented in PLearn::RBMConv2DConnection, PLearn::RBMDiagonalMatrixConnection, PLearn::RBMMatrixConnection, PLearn::RBMMatrixTransposeConnection, PLearn::RBMMixedConnection, and PLearn::RBMSparse1DMatrixConnection.

Referenced by fprop().

Here is the caller graph for this function:

void PLearn::RBMConnection::declareMethods ( RemoteMethodMap rmm) [static, protected]

Declares the methods that are remote-callable.

Reimplemented from PLearn::OnlineLearningModule.

Reimplemented in PLearn::RBMSparse1DMatrixConnection.

Definition at line 115 of file RBMConnection.cc.

References PLearn::OnlineLearningModule::_getRemoteMethodMap_(), PLearn::declareMethod(), PLearn::RemoteMethodMap::inherited(), setAsDownInput(), and setAsUpInput().

{
    rmm.inherited(inherited::_getRemoteMethodMap_());

    declareMethod(rmm, "setAsDownInput", &RBMConnection::setAsDownInput,
                  (BodyDoc("Sets 'input_vec' to 'input', and 'going_up' to true. \n"
                           "Note that no data copy is made, so 'input' should not be modified \n"
                           "afterwards."),
                   ArgDoc("const Vec& input", "The input vector")));
    declareMethod(rmm, "setAsUpInput", &RBMConnection::setAsUpInput,
                  (BodyDoc("Sets 'input_vec' to 'input', and 'going_up' to false. \n"
                           "Note that no data copy is made, so 'input' should not be modified \n"
                           "afterwards."),
                   ArgDoc("const Vec& input", "The input vector")));
}

Here is the call graph for this function:

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

Declares the class options.

Reimplemented from PLearn::OnlineLearningModule.

Reimplemented in PLearn::RBMConv2DConnection, PLearn::RBMDiagonalMatrixConnection, PLearn::RBMMatrixConnection, PLearn::RBMMatrixConnectionNatGrad, PLearn::RBMMatrixTransposeConnection, PLearn::RBMMixedConnection, and PLearn::RBMSparse1DMatrixConnection.

Definition at line 73 of file RBMConnection.cc.

References PLearn::OptionBase::buildoption, PLearn::declareOption(), PLearn::OnlineLearningModule::declareOptions(), down_size, initialization_method, PLearn::OnlineLearningModule::input_size, learning_rate, PLearn::OptionBase::learntoption, momentum, PLearn::OnlineLearningModule::output_size, PLearn::redeclareOption(), and up_size.

Referenced by PLearn::RBMMatrixTransposeConnection::declareOptions(), PLearn::RBMMatrixConnection::declareOptions(), PLearn::RBMDiagonalMatrixConnection::declareOptions(), and PLearn::RBMConv2DConnection::declareOptions().

{
    declareOption(ol, "down_size", &RBMConnection::down_size,
                  OptionBase::buildoption,
                  "Number of units in down layer.");

    declareOption(ol, "up_size", &RBMConnection::up_size,
                  OptionBase::buildoption,
                  "Number of units in up layer.");

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

    declareOption(ol, "momentum", &RBMConnection::momentum,
                  OptionBase::buildoption,
                  "The momentum, used both in update() and bpropUpdate() "
                  "methods\n");

    declareOption(ol, "initialization_method",
                  &RBMConnection::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);

    redeclareOption(ol, "input_size", &RBMConnection::input_size,
                    OptionBase::learntoption,
                    "Equals to down_size");

    redeclareOption(ol, "output_size", &RBMConnection::output_size,
                    OptionBase::learntoption,
                    "Equals to up_size");
}

Here is the call graph for this function:

Here is the caller graph for this function:

static const PPath& PLearn::RBMConnection::declaringFile ( ) [inline, static]
RBMConnection * PLearn::RBMConnection::deepCopy ( CopiesMap copies) const [virtual]
void PLearn::RBMConnection::fprop ( const Vec input,
Vec output 
) const [virtual]

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

Reimplemented from PLearn::OnlineLearningModule.

Definition at line 305 of file RBMConnection.cc.

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

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

Here is the call graph for this function:

void PLearn::RBMConnection::fprop ( const Mat inputs,
Mat outputs 
) [virtual]

Mini-batch fprop.

Default implementation raises an error. SOON TO BE DEPRECATED, USE fprop(const TVec<Mat*>& ports_value)

Reimplemented from PLearn::OnlineLearningModule.

Definition at line 313 of file RBMConnection.cc.

References computeProducts(), PLearn::TMat< T >::length(), PLearn::OnlineLearningModule::output_size, PLearn::TMat< T >::resize(), and setAsDownInputs().

{
    int batch_size = inputs.length();
    // propagates the activations.
    setAsDownInputs(inputs);
    outputs.resize(batch_size, output_size);
    computeProducts(0, output_size, outputs);
}

Here is the call graph for this function:

void PLearn::RBMConnection::getAllWeights ( Mat rbm_weights) const [virtual]

provide the internal weight values (not a copy)

Reimplemented in PLearn::RBMMatrixConnection.

Definition at line 322 of file RBMConnection.cc.

References PLERROR.

{
    PLERROR("In RBMConnection::getAllWeights(): not implemented");
}
const TVec< string > & PLearn::RBMConnection::getPorts ( ) [virtual]

Return the list of ports in the module.

Reimplemented from PLearn::OnlineLearningModule.

Definition at line 366 of file RBMConnection.cc.

References ports.

{
    return ports;
}
const TMat< int > & PLearn::RBMConnection::getPortSizes ( ) [virtual]

Return the size of all ports.

Reimplemented from PLearn::OnlineLearningModule.

Definition at line 374 of file RBMConnection.cc.

References PLearn::OnlineLearningModule::port_sizes.

{
    return port_sizes;
}
void PLearn::RBMConnection::makeDeepCopyFromShallowCopy ( CopiesMap copies) [virtual]
virtual Vec PLearn::RBMConnection::makeParametersPointHere ( const Vec global_parameters) [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 RBMConnection.

Implemented in PLearn::RBMConv2DConnection, PLearn::RBMDiagonalMatrixConnection, PLearn::RBMMatrixConnection, PLearn::RBMMatrixTransposeConnection, and PLearn::RBMMixedConnection.

virtual int PLearn::RBMConnection::nParameters ( ) const [pure virtual]
void PLearn::RBMConnection::petiteCulotteOlivierCD ( const Vec pos_down_values,
const Vec pos_up_values,
const Vec neg_down_values,
const Vec neg_up_values,
Mat weights_gradient,
bool  accumulate = false 
) [virtual]

Computes the contrastive divergence gradient with respect to the weights given the positive and negative phase values.

Reimplemented in PLearn::RBMMatrixConnection.

Definition at line 353 of file RBMConnection.cc.

References PLERROR.

{
    PLERROR("In RBMConnection::petiteCulotteOlivierCD(): not implemented");
}
void PLearn::RBMConnection::petiteCulotteOlivierCD ( Mat weights_gradient,
bool  accumulate = false 
) [virtual]

Computes the contrastive divergence gradient with respect to the weights It should be noted that bpropCD does not call clearstats().

Reimplemented in PLearn::RBMMatrixConnection.

Definition at line 347 of file RBMConnection.cc.

References PLERROR.

{
    PLERROR("In RBMConnection::petiteCulotteOlivierCD(): not implemented");
}
void PLearn::RBMConnection::petiteCulotteOlivierUpdate ( const Vec input,
const Mat rbm_weights,
const Vec output,
Vec input_gradient,
Mat rbm_weights_gradient,
const Vec output_gradient,
bool  accumulate = false 
) [virtual]

back-propagates the output gradient to the input and the weights (the weights are not updated)

Reimplemented in PLearn::RBMMatrixConnection.

Definition at line 332 of file RBMConnection.cc.

References PLERROR.

{
    PLERROR("In RBMConnection::bpropUpdate(): not implemented");
}
void PLearn::RBMConnection::setAllWeights ( const Mat rbm_weights) [virtual]

set the internal weight values to rbm_weights (not a copy)

Reimplemented in PLearn::RBMMatrixConnection.

Definition at line 327 of file RBMConnection.cc.

References PLERROR.

{
    PLERROR("In RBMConnection::setAllWeights(): not implemented");
}
void PLearn::RBMConnection::setAsDownInput ( const Vec input) const [virtual]

Sets 'input_vec' to 'input', and 'going_up' to true.

Note that no data copy is made, so 'input' should not be modified afterwards.

Reimplemented in PLearn::RBMMixedConnection.

Definition at line 230 of file RBMConnection.cc.

References down_size, going_up, input_vec, PLASSERT, and PLearn::TVec< T >::size().

Referenced by declareMethods(), fprop(), and PLearn::PseudolikelihoodRBM::train().

{
    PLASSERT( input.size() == down_size );
    input_vec = input;
    going_up = true;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void PLearn::RBMConnection::setAsDownInputs ( const Mat inputs) const [virtual]

Set 'inputs_mat' to 'inputs', and 'going_up' to true.

Note that no data copy is made, so 'inputs' should not be modified afterwards.

Reimplemented in PLearn::RBMMixedConnection.

Definition at line 240 of file RBMConnection.cc.

References down_size, going_up, inputs_mat, PLASSERT, and PLearn::TMat< T >::width().

Referenced by PLearn::PseudolikelihoodRBM::compute_Z(), and fprop().

{
    PLASSERT( inputs.width() == down_size );
    inputs_mat = inputs;
    going_up = true;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void PLearn::RBMConnection::setAsUpInput ( const Vec input) const [virtual]

Sets 'input_vec' to 'input', and 'going_up' to false.

Note that no data copy is made, so 'input' should not be modified afterwards.

Reimplemented in PLearn::RBMMixedConnection.

Definition at line 210 of file RBMConnection.cc.

References going_up, input_vec, PLASSERT, PLearn::TVec< T >::size(), and up_size.

Referenced by declareMethods(), and PLearn::PseudolikelihoodRBM::train().

{
    PLASSERT( input.size() == up_size );
    input_vec = input;
    going_up = false;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void PLearn::RBMConnection::setAsUpInputs ( const Mat inputs) const [virtual]

Set 'inputs_mat' to 'inputs', and 'going_up' to false.

Note that no data copy is made, so 'inputs' should not be modified afterwards.

Reimplemented in PLearn::RBMMixedConnection.

Definition at line 220 of file RBMConnection.cc.

References going_up, inputs_mat, PLASSERT, up_size, and PLearn::TMat< T >::width().

Referenced by PLearn::PseudolikelihoodRBM::compute_Z().

{
    PLASSERT( inputs.width() == up_size );
    inputs_mat = inputs;
    going_up = false;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void PLearn::RBMConnection::setLearningRate ( real  the_learning_rate) [virtual]

Sets the learning rate.

Reimplemented from PLearn::OnlineLearningModule.

Reimplemented in PLearn::RBMMixedConnection.

Definition at line 194 of file RBMConnection.cc.

References learning_rate.

{
    learning_rate = the_learning_rate;
}
void PLearn::RBMConnection::setMomentum ( real  the_momentum) [virtual]

Sets the momentum.

Reimplemented in PLearn::RBMMixedConnection.

Definition at line 202 of file RBMConnection.cc.

References momentum.

{
    momentum = the_momentum;
}
virtual void PLearn::RBMConnection::update ( ) [pure virtual]

Updates parameters according to contrastive divergence gradient.

Implemented in PLearn::RBMConv2DConnection, PLearn::RBMDiagonalMatrixConnection, PLearn::RBMMatrixConnection, PLearn::RBMMatrixTransposeConnection, and PLearn::RBMMixedConnection.

Referenced by update().

Here is the caller graph for this function:

void PLearn::RBMConnection::update ( const Mat pos_down_values,
const Mat pos_up_values,
const Mat neg_down_values,
const Mat neg_up_values 
) [virtual]

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

Reimplemented in PLearn::RBMConv2DConnection, PLearn::RBMDiagonalMatrixConnection, PLearn::RBMMatrixConnection, PLearn::RBMMatrixConnectionNatGrad, PLearn::RBMMixedConnection, and PLearn::RBMSparse1DMatrixConnection.

Definition at line 261 of file RBMConnection.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:

void PLearn::RBMConnection::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::RBMConv2DConnection, PLearn::RBMDiagonalMatrixConnection, PLearn::RBMMatrixConnection, PLearn::RBMMatrixTransposeConnection, and PLearn::RBMMixedConnection.

Definition at line 250 of file RBMConnection.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:

void PLearn::RBMConnection::updateCDandGibbs ( const Mat pos_down_values,
const Mat pos_up_values,
const Mat cd_neg_down_values,
const Mat cd_neg_up_values,
const Mat gibbs_neg_down_values,
const Mat gibbs_neg_up_values,
real  background_gibbs_update_ratio 
) [virtual]

Reimplemented in PLearn::RBMMatrixConnection.

Definition at line 279 of file RBMConnection.cc.

References PLASSERT_MSG.

{
    PLASSERT_MSG(false, "Not implemented by subclass!");
}
void PLearn::RBMConnection::updateGibbs ( const Mat pos_down_values,
const Mat pos_up_values,
const Mat gibbs_neg_down_values,
const Mat gibbs_neg_up_values 
) [virtual]

Reimplemented in PLearn::RBMMatrixConnection.

Definition at line 294 of file RBMConnection.cc.

References PLASSERT_MSG.

{
    PLASSERT_MSG(false, "Not implemented by subclass!");
}

Member Data Documentation

Number of units in down layer.

Definition at line 79 of file RBMConnection.h.

Referenced by PLearn::RBMDiagonalMatrixConnection::addWeightPenalty(), PLearn::RBMMatrixConnection::applyWeightPenalty(), PLearn::RBMDiagonalMatrixConnection::applyWeightPenalty(), PLearn::RBMSparse1DMatrixConnection::bpropAccUpdate(), PLearn::RBMConv2DConnection::bpropAccUpdate(), PLearn::RBMMatrixConnection::bpropAccUpdate(), PLearn::RBMMatrixConnection::bpropUpdate(), PLearn::RBMSparse1DMatrixConnection::bpropUpdate(), PLearn::RBMMatrixTransposeConnection::bpropUpdate(), PLearn::RBMDiagonalMatrixConnection::bpropUpdate(), PLearn::RBMMatrixConnectionNatGrad::bpropUpdate(), PLearn::RBMConv2DConnection::bpropUpdate(), PLearn::RBMConv2DConnection::build_(), PLearn::RBMMatrixConnectionNatGrad::build_(), PLearn::RBMMatrixConnection::build_(), PLearn::RBMMatrixTransposeConnection::build_(), build_(), PLearn::RBMSparse1DMatrixConnection::build_(), PLearn::RBMDiagonalMatrixConnection::build_(), PLearn::RBMMatrixConnection::computeProduct(), PLearn::RBMMatrixTransposeConnection::computeProduct(), PLearn::RBMMatrixConnection::computeProducts(), PLearn::RBMSparse1DMatrixConnection::computeProducts(), PLearn::RBMMatrixTransposeConnection::computeProducts(), PLearn::RBMConv2DConnection::computeProducts(), declareOptions(), PLearn::RBMConv2DConnection::declareOptions(), PLearn::RBMMixedConnection::declareOptions(), PLearn::RBMMatrixTransposeConnection::declareOptions(), PLearn::RBMMatrixConnection::forget(), PLearn::RBMDiagonalMatrixConnection::forget(), PLearn::RBMSparse1DMatrixConnection::getWeights(), PLearn::RBMMatrixConnection::petiteCulotteOlivierUpdate(), setAsDownInput(), setAsDownInputs(), PLearn::RBMSparse1DMatrixConnection::update(), and PLearn::RBMConv2DConnection::update().

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

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 74 of file RBMConnection.h.

Referenced by build_(), declareOptions(), PLearn::RBMMixedConnection::declareOptions(), PLearn::RBMSparse1DMatrixConnection::forget(), PLearn::RBMMatrixConnection::forget(), PLearn::RBMConv2DConnection::forget(), and PLearn::RBMDiagonalMatrixConnection::forget().

Vec PLearn::RBMConnection::input_vec [mutable, protected]
Mat PLearn::RBMConnection::inputs_mat [mutable, protected]
TVec<string> PLearn::RBMConnection::ports [protected]

Port names.

Definition at line 267 of file RBMConnection.h.

Referenced by build_(), and getPorts().

Number of units in up layer.

Definition at line 82 of file RBMConnection.h.

Referenced by PLearn::RBMSparse1DMatrixConnection::accumulateNegStats(), PLearn::RBMDiagonalMatrixConnection::accumulateNegStats(), PLearn::RBMDiagonalMatrixConnection::accumulatePosStats(), PLearn::RBMSparse1DMatrixConnection::accumulatePosStats(), PLearn::RBMMatrixConnection::applyWeightPenalty(), PLearn::RBMSparse1DMatrixConnection::bpropAccUpdate(), PLearn::RBMConv2DConnection::bpropAccUpdate(), PLearn::RBMMatrixConnection::bpropAccUpdate(), PLearn::RBMMatrixConnection::bpropUpdate(), PLearn::RBMSparse1DMatrixConnection::bpropUpdate(), PLearn::RBMMatrixTransposeConnection::bpropUpdate(), PLearn::RBMDiagonalMatrixConnection::bpropUpdate(), PLearn::RBMMatrixConnectionNatGrad::bpropUpdate(), PLearn::RBMConv2DConnection::bpropUpdate(), PLearn::RBMConv2DConnection::build_(), PLearn::RBMMatrixConnectionNatGrad::build_(), PLearn::RBMMatrixConnection::build_(), PLearn::RBMMatrixTransposeConnection::build_(), build_(), PLearn::RBMSparse1DMatrixConnection::build_(), PLearn::RBMDiagonalMatrixConnection::build_(), PLearn::RBMDiagonalMatrixConnection::computeProduct(), PLearn::RBMMatrixConnection::computeProduct(), PLearn::RBMMatrixTransposeConnection::computeProduct(), PLearn::RBMMatrixConnection::computeProducts(), PLearn::RBMSparse1DMatrixConnection::computeProducts(), PLearn::RBMMatrixTransposeConnection::computeProducts(), PLearn::RBMConv2DConnection::computeProducts(), declareOptions(), PLearn::RBMConv2DConnection::declareOptions(), PLearn::RBMMixedConnection::declareOptions(), PLearn::RBMMatrixTransposeConnection::declareOptions(), PLearn::RBMSparse1DMatrixConnection::forget(), PLearn::RBMMatrixConnection::forget(), PLearn::RBMDiagonalMatrixConnection::forget(), PLearn::RBMSparse1DMatrixConnection::getWeights(), PLearn::RBMMatrixConnection::petiteCulotteOlivierUpdate(), setAsUpInput(), setAsUpInputs(), PLearn::RBMSparse1DMatrixConnection::update(), PLearn::RBMMatrixConnectionNatGrad::update(), and PLearn::RBMConv2DConnection::update().


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