PLearn 0.1
|
Virtual class for the parameters between two layers of an RBM. More...
#include <RBMConnection.h>
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 RBMConnection * | deepCopy (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 PPath & | declaringFile () |
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. |
Virtual class for the parameters between two layers of an RBM.
Definition at line 56 of file RBMConnection.h.
typedef OnlineLearningModule PLearn::RBMConnection::inherited [private] |
Reimplemented from PLearn::OnlineLearningModule.
Reimplemented in PLearn::RBMConv2DConnection, PLearn::RBMDiagonalMatrixConnection, PLearn::RBMMatrixConnection, PLearn::RBMMatrixConnectionNatGrad, PLearn::RBMMatrixTransposeConnection, PLearn::RBMMixedConnection, and PLearn::RBMSparse1DMatrixConnection.
Definition at line 58 of file RBMConnection.h.
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_(); }
string PLearn::RBMConnection::_classname_ | ( | ) | [static] |
Reimplemented from PLearn::OnlineLearningModule.
Reimplemented in PLearn::RBMConv2DConnection, PLearn::RBMDiagonalMatrixConnection, PLearn::RBMMatrixConnection, PLearn::RBMMatrixConnectionNatGrad, PLearn::RBMMatrixTransposeConnection, PLearn::RBMMixedConnection, and PLearn::RBMSparse1DMatrixConnection.
Definition at line 51 of file RBMConnection.cc.
OptionList & PLearn::RBMConnection::_getOptionList_ | ( | ) | [static] |
Reimplemented from PLearn::OnlineLearningModule.
Reimplemented in PLearn::RBMConv2DConnection, PLearn::RBMDiagonalMatrixConnection, PLearn::RBMMatrixConnection, PLearn::RBMMatrixConnectionNatGrad, PLearn::RBMMatrixTransposeConnection, PLearn::RBMMixedConnection, and PLearn::RBMSparse1DMatrixConnection.
Definition at line 51 of file RBMConnection.cc.
RemoteMethodMap & PLearn::RBMConnection::_getRemoteMethodMap_ | ( | ) | [static] |
Reimplemented from PLearn::OnlineLearningModule.
Reimplemented in PLearn::RBMConv2DConnection, PLearn::RBMDiagonalMatrixConnection, PLearn::RBMMatrixConnection, PLearn::RBMMatrixConnectionNatGrad, PLearn::RBMMatrixTransposeConnection, PLearn::RBMMixedConnection, and PLearn::RBMSparse1DMatrixConnection.
Definition at line 51 of file RBMConnection.cc.
Reimplemented from PLearn::OnlineLearningModule.
Reimplemented in PLearn::RBMConv2DConnection, PLearn::RBMDiagonalMatrixConnection, PLearn::RBMMatrixConnection, PLearn::RBMMatrixConnectionNatGrad, PLearn::RBMMatrixTransposeConnection, PLearn::RBMMixedConnection, and PLearn::RBMSparse1DMatrixConnection.
Definition at line 51 of file RBMConnection.cc.
StaticInitializer RBMConnection::_static_initializer_ & PLearn::RBMConnection::_static_initialize_ | ( | ) | [static] |
Reimplemented from PLearn::OnlineLearningModule.
Reimplemented in PLearn::RBMConv2DConnection, PLearn::RBMDiagonalMatrixConnection, PLearn::RBMMatrixConnection, PLearn::RBMMatrixConnectionNatGrad, PLearn::RBMMatrixTransposeConnection, PLearn::RBMMixedConnection, and PLearn::RBMSparse1DMatrixConnection.
Definition at line 51 of file RBMConnection.cc.
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().
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().
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().
{ inherited::build(); build_(); }
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; }
virtual void PLearn::RBMConnection::clearStats | ( | ) | [pure virtual] |
Clear all information accumulated during stats.
Implemented in PLearn::RBMConv2DConnection, PLearn::RBMDiagonalMatrixConnection, PLearn::RBMMatrixConnection, PLearn::RBMMatrixTransposeConnection, and PLearn::RBMMixedConnection.
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().
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().
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"))); }
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"); }
static const PPath& PLearn::RBMConnection::declaringFile | ( | ) | [inline, static] |
Reimplemented from PLearn::OnlineLearningModule.
Reimplemented in PLearn::RBMConv2DConnection, PLearn::RBMDiagonalMatrixConnection, PLearn::RBMMatrixConnection, PLearn::RBMMatrixConnectionNatGrad, PLearn::RBMMatrixTransposeConnection, PLearn::RBMMixedConnection, and PLearn::RBMSparse1DMatrixConnection.
Definition at line 240 of file RBMConnection.h.
:
//##### Not Options #####################################################
RBMConnection * PLearn::RBMConnection::deepCopy | ( | CopiesMap & | copies | ) | const [virtual] |
Reimplemented from PLearn::OnlineLearningModule.
Reimplemented in PLearn::RBMConv2DConnection, PLearn::RBMDiagonalMatrixConnection, PLearn::RBMMatrixConnection, PLearn::RBMMatrixConnectionNatGrad, PLearn::RBMMatrixTransposeConnection, PLearn::RBMMixedConnection, and PLearn::RBMSparse1DMatrixConnection.
Definition at line 51 of file RBMConnection.cc.
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 ); }
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); }
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; }
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] |
Transforms a shallow copy into a deep copy.
Reimplemented from PLearn::OnlineLearningModule.
Reimplemented in PLearn::RBMConv2DConnection, PLearn::RBMDiagonalMatrixConnection, PLearn::RBMMatrixConnection, PLearn::RBMMatrixConnectionNatGrad, PLearn::RBMMatrixTransposeConnection, and PLearn::RBMMixedConnection.
Definition at line 183 of file RBMConnection.cc.
References PLearn::deepCopyField(), input_vec, inputs_mat, and PLearn::OnlineLearningModule::makeDeepCopyFromShallowCopy().
Referenced by PLearn::RBMMatrixTransposeConnection::makeDeepCopyFromShallowCopy(), PLearn::RBMMatrixConnection::makeDeepCopyFromShallowCopy(), PLearn::RBMDiagonalMatrixConnection::makeDeepCopyFromShallowCopy(), and PLearn::RBMConv2DConnection::makeDeepCopyFromShallowCopy().
{ inherited::makeDeepCopyFromShallowCopy(copies); deepCopyField(input_vec, copies); deepCopyField(inputs_mat, copies); }
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] |
return the number of parameters
Implemented in PLearn::RBMConv2DConnection, PLearn::RBMDiagonalMatrixConnection, PLearn::RBMMatrixConnection, PLearn::RBMMatrixTransposeConnection, PLearn::RBMMixedConnection, and PLearn::RBMSparse1DMatrixConnection.
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().
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; }
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().
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; }
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().
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(); }
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(); }
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!"); }
Reimplemented from PLearn::OnlineLearningModule.
Reimplemented in PLearn::RBMConv2DConnection, PLearn::RBMDiagonalMatrixConnection, PLearn::RBMMatrixConnection, PLearn::RBMMatrixConnectionNatGrad, PLearn::RBMMatrixTransposeConnection, PLearn::RBMMixedConnection, and PLearn::RBMSparse1DMatrixConnection.
Definition at line 240 of file RBMConnection.h.
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] |
Tells if input_vec comes from down (true) or up (false)
Definition at line 258 of file RBMConnection.h.
Referenced by PLearn::RBMMatrixConnection::computeProduct(), PLearn::RBMMatrixTransposeConnection::computeProduct(), PLearn::RBMMatrixConnection::computeProducts(), PLearn::RBMSparse1DMatrixConnection::computeProducts(), PLearn::RBMMatrixTransposeConnection::computeProducts(), PLearn::RBMConv2DConnection::computeProducts(), setAsDownInput(), setAsDownInputs(), setAsUpInput(), and setAsUpInputs().
The method used to initialize the weights:
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] |
Pointer to current input vector.
Definition at line 252 of file RBMConnection.h.
Referenced by PLearn::RBMDiagonalMatrixConnection::computeProduct(), PLearn::RBMMatrixConnection::computeProduct(), PLearn::RBMMatrixTransposeConnection::computeProduct(), makeDeepCopyFromShallowCopy(), setAsDownInput(), and setAsUpInput().
Mat PLearn::RBMConnection::inputs_mat [mutable, protected] |
Pointer to current inputs matrix.
Definition at line 255 of file RBMConnection.h.
Referenced by PLearn::RBMMatrixConnection::computeProducts(), PLearn::RBMSparse1DMatrixConnection::computeProducts(), PLearn::RBMMatrixTransposeConnection::computeProducts(), PLearn::RBMConv2DConnection::computeProducts(), PLearn::RBMDiagonalMatrixConnection::computeProducts(), makeDeepCopyFromShallowCopy(), setAsDownInputs(), and setAsUpInputs().
The learning rate, used both in update() and bpropUpdate() methods.
Definition at line 64 of file RBMConnection.h.
Referenced by PLearn::RBMDiagonalMatrixConnection::applyWeightPenalty(), 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(), declareOptions(), setLearningRate(), PLearn::RBMSparse1DMatrixConnection::update(), PLearn::RBMDiagonalMatrixConnection::update(), PLearn::RBMMatrixConnection::update(), PLearn::RBMMatrixConnectionNatGrad::update(), PLearn::RBMMatrixTransposeConnection::update(), PLearn::RBMConv2DConnection::update(), PLearn::RBMMatrixConnection::updateCDandGibbs(), and PLearn::RBMMatrixConnection::updateGibbs().
Momentum for the gradient descent.
Definition at line 67 of file RBMConnection.h.
Referenced by PLearn::RBMConv2DConnection::build_(), PLearn::RBMMatrixConnection::build_(), PLearn::RBMMatrixTransposeConnection::build_(), PLearn::RBMSparse1DMatrixConnection::build_(), PLearn::RBMDiagonalMatrixConnection::build_(), declareOptions(), setMomentum(), PLearn::RBMSparse1DMatrixConnection::update(), PLearn::RBMDiagonalMatrixConnection::update(), PLearn::RBMMatrixConnectionNatGrad::update(), PLearn::RBMMatrixConnection::update(), PLearn::RBMMatrixTransposeConnection::update(), and PLearn::RBMConv2DConnection::update().
int PLearn::RBMConnection::neg_count [protected] |
Number of examples accumulated in *_neg_stats.
Definition at line 264 of file RBMConnection.h.
Referenced by PLearn::RBMMatrixTransposeConnection::accumulateNegStats(), PLearn::RBMConv2DConnection::accumulateNegStats(), PLearn::RBMSparse1DMatrixConnection::accumulateNegStats(), PLearn::RBMDiagonalMatrixConnection::accumulateNegStats(), PLearn::RBMMatrixConnection::accumulateNegStats(), PLearn::RBMMatrixTransposeConnection::clearStats(), PLearn::RBMMatrixConnection::clearStats(), PLearn::RBMConv2DConnection::clearStats(), PLearn::RBMDiagonalMatrixConnection::clearStats(), PLearn::RBMMatrixConnection::petiteCulotteOlivierCD(), PLearn::RBMDiagonalMatrixConnection::update(), PLearn::RBMMatrixConnection::update(), PLearn::RBMMatrixTransposeConnection::update(), PLearn::RBMConv2DConnection::update(), PLearn::RBMMatrixConnection::updateCDandGibbs(), and PLearn::RBMMatrixConnection::updateGibbs().
TVec<string> PLearn::RBMConnection::ports [protected] |
int PLearn::RBMConnection::pos_count [protected] |
Number of examples accumulated in *_pos_stats.
Definition at line 261 of file RBMConnection.h.
Referenced by PLearn::RBMDiagonalMatrixConnection::accumulatePosStats(), PLearn::RBMMatrixConnection::accumulatePosStats(), PLearn::RBMMatrixTransposeConnection::accumulatePosStats(), PLearn::RBMConv2DConnection::accumulatePosStats(), PLearn::RBMSparse1DMatrixConnection::accumulatePosStats(), PLearn::RBMMatrixConnectionNatGrad::bpropUpdate(), PLearn::RBMMatrixTransposeConnection::clearStats(), PLearn::RBMMatrixConnection::clearStats(), PLearn::RBMConv2DConnection::clearStats(), PLearn::RBMDiagonalMatrixConnection::clearStats(), PLearn::RBMMatrixConnection::petiteCulotteOlivierCD(), PLearn::RBMDiagonalMatrixConnection::update(), PLearn::RBMMatrixConnectionNatGrad::update(), PLearn::RBMMatrixConnection::update(), PLearn::RBMMatrixTransposeConnection::update(), and PLearn::RBMConv2DConnection::update().
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().