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 | Private Attributes
PLearn::RBMMixedLayer Class Reference

Layer in an RBM formed with binomial units. More...

#include <RBMMixedLayer.h>

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

List of all members.

Public Member Functions

 RBMMixedLayer ()
 Default constructor.
 RBMMixedLayer (TVec< PP< RBMLayer > > the_sub_layers)
 Constructor from the sub_layers.
virtual void getUnitActivations (int i, PP< RBMParameters > rbmp, int offset=0)
 Uses "rbmp" to obtain the activations of unit "i" of this layer.
virtual void getAllActivations (PP< RBMParameters > rbmp, int offset=0)
 Uses "rbmp" to obtain the activations of all units in this layer.
virtual void generateSample ()
 compute a sample, and update the sample field
virtual void computeExpectation ()
 compute the expectation
virtual void bpropUpdate (const Vec &input, const Vec &output, Vec &input_gradient, const Vec &output_gradient)
 back-propagates the output gradient to the input
virtual string classname () const
virtual OptionListgetOptionList () const
virtual OptionMapgetOptionMap () const
virtual RemoteMethodMapgetRemoteMethodMap () const
virtual RBMMixedLayerdeepCopy (CopiesMap &copies) const
virtual void build ()
 Post-constructor.
virtual void makeDeepCopyFromShallowCopy (CopiesMap &copies)
 Transforms a shallow copy into a deep copy.
 RBMMixedLayer ()
 Default constructor.
 RBMMixedLayer (TVec< PP< RBMLayer > > the_sub_layers)
 Constructor from the sub_layers.
virtual void setLearningRate (real the_learning_rate)
 Sets the learning rate, also in the sub_layers.
virtual void setMomentum (real the_momentum)
 Sets the momentum, also in the sub_layers.
virtual void setBatchSize (int the_batch_size)
 Sets batch_size and resize activations, expectations, and samples.
virtual void setExpectation (const Vec &the_expectation)
 Copy the given expectation in the 'expectation' vector.
virtual void setExpectationByRef (const Vec &the_expectation)
 Make the 'expectation' vector point to the given data vector (so no copy is performed).
virtual void setExpectations (const Mat &the_expectations)
 Copy the given expectations in the 'expectations' matrix.
virtual void setExpectationsByRef (const Mat &the_expectations)
 Make the 'expectations' matrix point to the given data matrix (so no copy is performed).
virtual void getUnitActivation (int i, PP< RBMConnection > rbmc, int offset=0)
 Uses "rbmc" to compute the activation of unit "i" of this layer.
virtual void getAllActivations (PP< RBMConnection > rbmc, int offset=0, bool minibatch=false)
 Uses "rbmc" to obtain the activations of all units in this layer.
virtual void expectation_is_not_up_to_date ()
virtual void generateSample ()
 compute a sample, and update the sample field
virtual void generateSamples ()
 generate activations.length() samples
virtual void computeExpectation ()
 compute the expectation
virtual void computeExpectations ()
 compute the expectations according to activations
virtual void fprop (const Vec &input, Vec &output) const
 forward propagation
virtual void fprop (const Mat &inputs, Mat &outputs)
 Batch forward propagation.
virtual void fprop (const Vec &input, const Vec &rbm_bias, Vec &output) const
 forward propagation with provided bias
virtual void bpropUpdate (const Vec &input, const Vec &output, Vec &input_gradient, const Vec &output_gradient, bool accumulate=false)
 back-propagates the output gradient to the input
virtual void bpropUpdate (const Mat &inputs, const Mat &outputs, Mat &input_gradients, const Mat &output_gradients, bool accumulate=false)
 Back-propagate the output gradient to the input, and update parameters.
virtual void bpropUpdate (const Vec &input, const Vec &rbm_bias, const Vec &output, Vec &input_gradient, Vec &rbm_bias_gradient, const Vec &output_gradient)
 back-propagates the output gradient to the input and the bias
virtual real fpropNLL (const Vec &target)
 Computes the negative log-likelihood of target given the internal activations of the layer.
virtual void fpropNLL (const Mat &targets, const Mat &costs_column)
 Batch fpropNLL.
virtual void bpropNLL (const Vec &target, real nll, Vec &bias_gradient)
 Computes the gradient of the negative log-likelihood of target with respect to the layer's bias, given the internal activations.
virtual void bpropNLL (const Mat &targets, const Mat &costs_column, Mat &bias_gradients)
virtual void accumulatePosStats (const Vec &pos_values)
 Accumulates positive phase statistics.
virtual void accumulateNegStats (const Vec &neg_values)
 Accumulates negative phase statistics.
virtual void update ()
 Update parameters according to accumulated statistics.
virtual void update (const Vec &pos_values, const Vec &neg_values)
 Update parameters according to one pair of vectors.
virtual void update (const Mat &pos_values, const Mat &neg_values)
 Update parameters according to several pairs of vectors.
virtual void reset ()
 resets activations, sample and expectation fields
virtual void clearStats ()
 resets the statistics and counts
virtual void forget ()
 forgets everything
virtual real energy (const Vec &unit_values) const
 Compute -bias' unit_values.
virtual real freeEnergyContribution (const Vec &unit_activations) const
 Computes $ -log(\sum_{possible values of h} exp(h' unit_activations))$ This quantity is used for computing the free energy of a sample x in the OTHER layer of an RBM, from which unit_activations was computed.
virtual void freeEnergyContributionGradient (const Vec &unit_activations, Vec &unit_activations_gradient, real output_gradient=1, bool accumulate=false) const
 Computes gradient of the result of freeEnergyContribution $ -log(\sum_{possible values of h} exp(h' unit_activations))$ with respect to unit_activations.
virtual int getConfigurationCount ()
 Returns a number of different configurations the layer can be in.
virtual void getConfiguration (int conf_index, Vec &output)
 Computes the conf_index configuration of the layer.
virtual string classname () const
virtual OptionListgetOptionList () const
virtual OptionMapgetOptionMap () const
virtual RemoteMethodMapgetRemoteMethodMap () const
virtual RBMMixedLayerdeepCopy (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 Object_new_instance_for_typemap_ ()
static bool _isa_ (const Object *o)
static void _static_initialize_ ()
static const PPathdeclaringFile ()
static string _classname_ ()
static OptionList_getOptionList_ ()
static RemoteMethodMap_getRemoteMethodMap_ ()
static Object_new_instance_for_typemap_ ()
static bool _isa_ (const Object *o)
static void _static_initialize_ ()
static const PPathdeclaringFile ()

Public Attributes

TVec< PP< RBMLayer > > sub_layers
 The concatenated RBMLayers composing this layer.

Static Public Attributes

static StaticInitializer _static_initializer_

Static Protected Member Functions

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

Protected Attributes

TVec< intinit_positions
 Initial index of the sub_layers.
TVec< intlayer_of_unit
 layer_of_unit[i] is the index of sub_layer containing unit i
int n_layers
 Number of sub-layers.

Private Types

typedef RBMLayer inherited
typedef RBMLayer inherited

Private Member Functions

void build_ ()
 This does the actual building.
void build_ ()
 This does the actual building.

Private Attributes

Vec nlls
Mat mat_nlls

Detailed Description

Layer in an RBM formed with binomial units.

Layer in an RBM formed with the concatenation of other layers.

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

Definition at line 54 of file DEPRECATED/RBMMixedLayer.h.


Member Typedef Documentation

Reimplemented from PLearn::RBMLayer.

Definition at line 56 of file DEPRECATED/RBMMixedLayer.h.

Reimplemented from PLearn::RBMLayer.

Definition at line 55 of file RBMMixedLayer.h.


Constructor & Destructor Documentation

PLearn::RBMMixedLayer::RBMMixedLayer ( )

Default constructor.

Definition at line 51 of file DEPRECATED/RBMMixedLayer.cc.

{
}
PLearn::RBMMixedLayer::RBMMixedLayer ( TVec< PP< RBMLayer > >  the_sub_layers)

Constructor from the sub_layers.

Definition at line 55 of file DEPRECATED/RBMMixedLayer.cc.

References build().

                                                                  :
    sub_layers( the_sub_layers )
{
    build();
}

Here is the call graph for this function:

PLearn::RBMMixedLayer::RBMMixedLayer ( )

Default constructor.

PLearn::RBMMixedLayer::RBMMixedLayer ( TVec< PP< RBMLayer > >  the_sub_layers)

Constructor from the sub_layers.


Member Function Documentation

string PLearn::RBMMixedLayer::_classname_ ( ) [static]

Reimplemented from PLearn::RBMLayer.

Definition at line 49 of file DEPRECATED/RBMMixedLayer.cc.

static string PLearn::RBMMixedLayer::_classname_ ( ) [static]

Reimplemented from PLearn::RBMLayer.

OptionList & PLearn::RBMMixedLayer::_getOptionList_ ( ) [static]

Reimplemented from PLearn::RBMLayer.

Definition at line 49 of file DEPRECATED/RBMMixedLayer.cc.

static OptionList& PLearn::RBMMixedLayer::_getOptionList_ ( ) [static]

Reimplemented from PLearn::RBMLayer.

static RemoteMethodMap& PLearn::RBMMixedLayer::_getRemoteMethodMap_ ( ) [static]

Reimplemented from PLearn::RBMLayer.

RemoteMethodMap & PLearn::RBMMixedLayer::_getRemoteMethodMap_ ( ) [static]

Reimplemented from PLearn::RBMLayer.

Definition at line 49 of file DEPRECATED/RBMMixedLayer.cc.

static bool PLearn::RBMMixedLayer::_isa_ ( const Object o) [static]

Reimplemented from PLearn::RBMLayer.

bool PLearn::RBMMixedLayer::_isa_ ( const Object o) [static]

Reimplemented from PLearn::RBMLayer.

Definition at line 49 of file DEPRECATED/RBMMixedLayer.cc.

static Object* PLearn::RBMMixedLayer::_new_instance_for_typemap_ ( ) [static]

Reimplemented from PLearn::Object.

Object * PLearn::RBMMixedLayer::_new_instance_for_typemap_ ( ) [static]

Reimplemented from PLearn::Object.

Definition at line 49 of file DEPRECATED/RBMMixedLayer.cc.

StaticInitializer RBMMixedLayer::_static_initializer_ & PLearn::RBMMixedLayer::_static_initialize_ ( ) [static]

Reimplemented from PLearn::RBMLayer.

Definition at line 49 of file DEPRECATED/RBMMixedLayer.cc.

static void PLearn::RBMMixedLayer::_static_initialize_ ( ) [static]

Reimplemented from PLearn::RBMLayer.

void PLearn::RBMMixedLayer::accumulateNegStats ( const Vec neg_values) [virtual]

Accumulates negative phase statistics.

Reimplemented from PLearn::RBMLayer.

Definition at line 545 of file RBMMixedLayer.cc.

References i, init_positions, n_layers, PLearn::RBMLayer::neg_count, PLearn::RBMLayer::size, sub_layers, and PLearn::TVec< T >::subVec().

{
    for( int i=0 ; i<n_layers ; i++ )
    {
        Vec sub_neg_values = neg_values.subVec( init_positions[i],
                                                sub_layers[i]->size );
        sub_layers[i]->accumulateNegStats( sub_neg_values );
    }
    neg_count++;
}

Here is the call graph for this function:

void PLearn::RBMMixedLayer::accumulatePosStats ( const Vec pos_values) [virtual]

Accumulates positive phase statistics.

Reimplemented from PLearn::RBMLayer.

Definition at line 534 of file RBMMixedLayer.cc.

References i, init_positions, n_layers, PLearn::RBMLayer::pos_count, PLearn::RBMLayer::size, sub_layers, and PLearn::TVec< T >::subVec().

{
    for( int i=0 ; i<n_layers ; i++ )
    {
        Vec sub_pos_values = pos_values.subVec( init_positions[i],
                                                sub_layers[i]->size );
        sub_layers[i]->accumulatePosStats( sub_pos_values );
    }
    pos_count++;
}

Here is the call graph for this function:

void PLearn::RBMMixedLayer::bpropNLL ( const Mat targets,
const Mat costs_column,
Mat bias_gradients 
) [virtual]

Reimplemented from PLearn::RBMLayer.

Definition at line 475 of file RBMMixedLayer.cc.

References PLearn::RBMLayer::batch_size, PLearn::TMat< T >::column(), computeExpectations(), i, init_positions, PLearn::OnlineLearningModule::input_size, PLearn::TMat< T >::length(), mat_nlls, n_layers, PLASSERT, PLearn::TMat< T >::resize(), PLearn::TVec< T >::size(), PLearn::RBMLayer::size, sub_layers, PLearn::TMat< T >::subMatColumns(), and PLearn::TMat< T >::width().

{
    computeExpectations();

    PLASSERT( targets.width() == input_size );
    PLASSERT( targets.length() == batch_size );
    PLASSERT( costs_column.width() == 1 );
    PLASSERT( costs_column.length() == batch_size );
    bias_gradients.resize( batch_size, size );

    for( int i=0 ; i<n_layers ; i++ )
    {
        int begin = init_positions[i];
        int size_i = sub_layers[i]->size;

        Mat sub_targets = targets.subMatColumns(begin, size_i);
        Mat sub_bias_gradients = bias_gradients.subMatColumns(begin, size_i);
        // TODO: something else than store mat_nlls...
        sub_layers[i]->bpropNLL( sub_targets, mat_nlls.column(i),
                                 sub_bias_gradients );
    }
}

Here is the call graph for this function:

void PLearn::RBMMixedLayer::bpropNLL ( const Vec target,
real  nll,
Vec bias_gradient 
) [virtual]

Computes the gradient of the negative log-likelihood of target with respect to the layer's bias, given the internal activations.

Reimplemented from PLearn::RBMLayer.

Definition at line 457 of file RBMMixedLayer.cc.

References computeExpectation(), i, init_positions, PLearn::OnlineLearningModule::input_size, n_layers, nlls, PLASSERT, PLearn::TVec< T >::resize(), PLearn::TVec< T >::size(), PLearn::RBMLayer::size, sub_layers, and PLearn::TVec< T >::subVec().

{
    computeExpectation();

    PLASSERT( target.size() == input_size );
    bias_gradient.resize( size );

    for( int i=0 ; i<n_layers ; i++ )
    {
        int begin = init_positions[i];
        int size_i = sub_layers[i]->size;

        Vec sub_target = target.subVec(begin, size_i);
        Vec sub_bias_gradient = bias_gradient.subVec(begin, size_i);
        sub_layers[i]->bpropNLL( sub_target, nlls[i], sub_bias_gradient );
    }
}

Here is the call graph for this function:

void PLearn::RBMMixedLayer::bpropUpdate ( const Vec input,
const Vec output,
Vec input_gradient,
const Vec output_gradient,
bool  accumulate = false 
) [virtual]

back-propagates the output gradient to the input

Implements PLearn::RBMLayer.

Definition at line 310 of file RBMMixedLayer.cc.

References i, init_positions, n_layers, PLASSERT, PLASSERT_MSG, PLearn::TVec< T >::resize(), PLearn::TVec< T >::size(), PLearn::RBMLayer::size, sub_layers, and PLearn::TVec< T >::subVec().

{
    PLASSERT( input.size() == size );
    PLASSERT( output.size() == size );
    PLASSERT( output_gradient.size() == size );

    if( accumulate )
    {
        PLASSERT_MSG( input_gradient.size() == size,
                      "Cannot resize input_gradient AND accumulate into it" );
    }
    else
        // Note that, by construction of 'size', the whole gradient vector
        // should be cleared in the calls to sub_layers->bpropUpdate(..) below.
        input_gradient.resize( size );

    for( int i=0 ; i<n_layers ; i++ )
    {
        int begin = init_positions[i];
        int size_i = sub_layers[i]->size;
        Vec sub_input = input.subVec( begin, size_i );
        Vec sub_output = output.subVec( begin, size_i );
        Vec sub_input_gradient = input_gradient.subVec( begin, size_i );
        Vec sub_output_gradient = output_gradient.subVec( begin, size_i );

        sub_layers[i]->bpropUpdate( sub_input, sub_output,
                                    sub_input_gradient, sub_output_gradient,
                                    accumulate );
    }
}

Here is the call graph for this function:

void PLearn::RBMMixedLayer::bpropUpdate ( const Mat inputs,
const Mat outputs,
Mat input_gradients,
const Mat output_gradients,
bool  accumulate = false 
) [virtual]

Back-propagate the output gradient to the input, and update parameters.

Implements PLearn::RBMLayer.

Definition at line 344 of file RBMMixedLayer.cc.

References PLearn::RBMLayer::batch_size, i, init_positions, PLearn::TMat< T >::length(), n_layers, PLASSERT, PLASSERT_MSG, PLearn::TMat< T >::resize(), PLearn::TVec< T >::size(), PLearn::RBMLayer::size, sub_layers, PLearn::TMat< T >::subMatColumns(), and PLearn::TMat< T >::width().

{
    PLASSERT( inputs.width() == size );
    PLASSERT( outputs.width() == size );
    PLASSERT( output_gradients.width() == size );

    int batch_size = inputs.length();
    PLASSERT( outputs.length() == batch_size );
    PLASSERT( output_gradients.length() == batch_size );

    if( accumulate )
    {
        PLASSERT_MSG( input_gradients.width() == size &&
                input_gradients.length() == batch_size,
                "Cannot resize input_gradients and accumulate into it" );
    }
    else
        // Note that, by construction of 'size', the whole gradient vector
        // should be cleared in the calls to sub_layers->bpropUpdate(..) below.
        input_gradients.resize(batch_size, size);

    for( int i=0 ; i<n_layers ; i++ )
    {
        int begin = init_positions[i];
        int size_i = sub_layers[i]->size;
        Mat sub_inputs = inputs.subMatColumns( begin, size_i );
        Mat sub_outputs = outputs.subMatColumns( begin, size_i );
        Mat sub_input_gradients =
            input_gradients.subMatColumns( begin, size_i );
        Mat sub_output_gradients =
            output_gradients.subMatColumns( begin, size_i );

        sub_layers[i]->bpropUpdate( sub_inputs, sub_outputs,
                sub_input_gradients, sub_output_gradients,
                accumulate );
    }
}

Here is the call graph for this function:

void PLearn::RBMMixedLayer::bpropUpdate ( const Vec input,
const Vec rbm_bias,
const Vec output,
Vec input_gradient,
Vec rbm_bias_gradient,
const Vec output_gradient 
) [virtual]

back-propagates the output gradient to the input and the bias

Reimplemented from PLearn::RBMLayer.

Definition at line 385 of file RBMMixedLayer.cc.

References i, init_positions, n_layers, PLASSERT, PLearn::TVec< T >::resize(), PLearn::TVec< T >::size(), PLearn::RBMLayer::size, sub_layers, and PLearn::TVec< T >::subVec().

{
    PLASSERT( input.size() == size );
    PLASSERT( rbm_bias.size() == size );
    PLASSERT( output.size() == size );
    PLASSERT( output_gradient.size() == size );

    input_gradient.resize( size );
    rbm_bias_gradient.resize( size );

    for( int i=0 ; i<n_layers ; i++ )
    {
        int begin = init_positions[i];
        int size_i = sub_layers[i]->size;
        Vec sub_input = input.subVec( begin, size_i );
        Vec sub_rbm_bias = rbm_bias.subVec( begin, size_i );
        Vec sub_output = output.subVec( begin, size_i );
        Vec sub_input_gradient = input_gradient.subVec( begin, size_i );
        Vec sub_rbm_bias_gradient = rbm_bias_gradient.subVec( begin, size_i);
        Vec sub_output_gradient = output_gradient.subVec( begin, size_i );

        sub_layers[i]->bpropUpdate( sub_input, sub_rbm_bias, sub_output,
                                    sub_input_gradient, sub_rbm_bias_gradient,
                                    sub_output_gradient );
    }
}

Here is the call graph for this function:

void PLearn::RBMMixedLayer::bpropUpdate ( const Vec input,
const Vec output,
Vec input_gradient,
const Vec output_gradient 
) [virtual]

back-propagates the output gradient to the input

Implements PLearn::RBMLayer.

Definition at line 104 of file DEPRECATED/RBMMixedLayer.cc.

References PLERROR.

{
    PLERROR( "RBMMixedLayer::bpropUpdate not implemented yet." );
}
virtual void PLearn::RBMMixedLayer::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::RBMLayer.

void PLearn::RBMMixedLayer::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::RBMLayer.

Definition at line 162 of file DEPRECATED/RBMMixedLayer.cc.

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

Referenced by RBMMixedLayer().

Here is the call graph for this function:

Here is the caller graph for this function:

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

This does the actual building.

Reimplemented from PLearn::RBMLayer.

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

This does the actual building.

Reimplemented from PLearn::RBMLayer.

Definition at line 134 of file DEPRECATED/RBMMixedLayer.cc.

References PLearn::RBMLayer::activations, PLearn::TVec< T >::append(), PLearn::RBMLayer::expectation, PLearn::RBMLayer::expectation_is_up_to_date, i, init_positions, layer_of_unit, PLearn::merge(), n_layers, PLearn::TVec< T >::resize(), PLearn::RBMLayer::sample, PLearn::TVec< T >::size(), PLearn::RBMLayer::size, sub_layers, and PLearn::RBMLayer::units_types.

Referenced by build().

{
    units_types = "";
    size = 0;
    activations.resize( 0 );
    sample.resize( 0 );
    expectation.resize( 0 );
    expectation_is_up_to_date = false;
    layer_of_unit.resize( 0 );

    n_layers = sub_layers.size();
    init_positions.resize( n_layers );

    for( int i=0 ; i<n_layers ; i++ )
    {
        init_positions[i] = size;

        PP<RBMLayer> cur_layer = sub_layers[i];
        units_types += cur_layer->units_types;
        size += cur_layer->size;

        activations = merge( activations, cur_layer->activations );
        sample = merge( sample, cur_layer->sample );
        expectation = merge( expectation, cur_layer->expectation );
        layer_of_unit.append( TVec<int>( cur_layer->size, i ) );
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

string PLearn::RBMMixedLayer::classname ( ) const [virtual]

Reimplemented from PLearn::Object.

Definition at line 49 of file DEPRECATED/RBMMixedLayer.cc.

virtual string PLearn::RBMMixedLayer::classname ( ) const [virtual]

Reimplemented from PLearn::Object.

void PLearn::RBMMixedLayer::clearStats ( ) [virtual]

resets the statistics and counts

Reimplemented from PLearn::RBMLayer.

Definition at line 598 of file RBMMixedLayer.cc.

References i, n_layers, PLearn::RBMLayer::neg_count, PLearn::RBMLayer::pos_count, and sub_layers.

Referenced by update().

{
    for( int i=0 ; i<n_layers ; i++ )
        sub_layers[i]->clearStats();

    pos_count = 0;
    neg_count = 0;
}

Here is the caller graph for this function:

void PLearn::RBMMixedLayer::computeExpectation ( ) [virtual]

compute the expectation

Implements PLearn::RBMLayer.

Definition at line 93 of file DEPRECATED/RBMMixedLayer.cc.

References PLearn::RBMLayer::expectation_is_up_to_date, i, n_layers, and sub_layers.

Referenced by bpropNLL(), and fpropNLL().

Here is the caller graph for this function:

virtual void PLearn::RBMMixedLayer::computeExpectation ( ) [virtual]

compute the expectation

Implements PLearn::RBMLayer.

void PLearn::RBMMixedLayer::computeExpectations ( ) [virtual]

compute the expectations according to activations

Implements PLearn::RBMLayer.

Definition at line 235 of file RBMMixedLayer.cc.

References PLearn::RBMLayer::expectations_are_up_to_date, i, n_layers, and sub_layers.

Referenced by bpropNLL().

Here is the caller graph for this function:

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

Declares the class options.

Reimplemented from PLearn::RBMLayer.

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

Declares the class options.

Reimplemented from PLearn::RBMLayer.

Definition at line 111 of file DEPRECATED/RBMMixedLayer.cc.

References PLearn::OptionBase::buildoption, PLearn::declareOption(), PLearn::RBMLayer::declareOptions(), init_positions, layer_of_unit, PLearn::OptionBase::learntoption, n_layers, and sub_layers.

{
    declareOption(ol, "sub_layers", &RBMMixedLayer::sub_layers,
                  OptionBase::buildoption,
                  "The concatenated RBMLayers composing this layer.");

    declareOption(ol, "init_positions", &RBMMixedLayer::init_positions,
                  OptionBase::learntoption,
                  " Initial index of the sub_layers.");

    declareOption(ol, "layer_of_unit", &RBMMixedLayer::layer_of_unit,
                  OptionBase::learntoption,
                  "layer_of_unit[i] is the index of sub_layer containing unit"
                  " i.");

    declareOption(ol, "n_layers", &RBMMixedLayer::n_layers,
                  OptionBase::learntoption,
                  "Number of sub-layers.");

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

Here is the call graph for this function:

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

Reimplemented from PLearn::RBMLayer.

Definition at line 211 of file RBMMixedLayer.h.

:

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

Reimplemented from PLearn::RBMLayer.

Definition at line 99 of file DEPRECATED/RBMMixedLayer.h.

:

virtual RBMMixedLayer* PLearn::RBMMixedLayer::deepCopy ( CopiesMap copies) const [virtual]

Reimplemented from PLearn::RBMLayer.

RBMMixedLayer * PLearn::RBMMixedLayer::deepCopy ( CopiesMap copies) const [virtual]

Reimplemented from PLearn::RBMLayer.

Definition at line 49 of file DEPRECATED/RBMMixedLayer.cc.

real PLearn::RBMMixedLayer::energy ( const Vec unit_values) const [virtual]

Compute -bias' unit_values.

Reimplemented from PLearn::RBMLayer.

Definition at line 713 of file RBMMixedLayer.cc.

References i, init_positions, n_layers, PLearn::TVec< T >::size(), sub_layers, and PLearn::TVec< T >::subVec().

{
    real energy = 0;

    for ( int i = 0; i < n_layers; ++i ) {
        int begin = init_positions[i];
        int size_i = sub_layers[i]->size;
        Vec values = unit_values.subVec( begin, size_i );
        energy += sub_layers[i]->energy(values);
    }

    return energy;
}

Here is the call graph for this function:

void PLearn::RBMMixedLayer::expectation_is_not_up_to_date ( ) [virtual]

Reimplemented from PLearn::RBMLayer.

Definition at line 192 of file RBMMixedLayer.cc.

References PLearn::RBMLayer::expectation_is_up_to_date, i, n_layers, and sub_layers.

void PLearn::RBMMixedLayer::forget ( ) [virtual]

forgets everything

Reimplemented from PLearn::RBMLayer.

Definition at line 607 of file RBMMixedLayer.cc.

References PLearn::RBMLayer::forget(), i, n_layers, PLWARNING, PLearn::RBMLayer::random_gen, and sub_layers.

{
    inherited::forget();
    if( !random_gen )
    {
        PLWARNING("RBMMixedLayer: cannot forget() without random_gen");
        return;
    }
    for( int i=0; i<n_layers; i++ )
    {
        if( !(sub_layers[i]->random_gen) )
            sub_layers[i]->random_gen = random_gen;
        sub_layers[i]->forget();
    }
}

Here is the call graph for this function:

void PLearn::RBMMixedLayer::fprop ( const Vec input,
Vec output 
) const [virtual]

forward propagation

Reimplemented from PLearn::RBMLayer.

Definition at line 249 of file RBMMixedLayer.cc.

References i, init_positions, PLearn::OnlineLearningModule::input_size, n_layers, PLearn::OnlineLearningModule::output_size, PLASSERT, PLearn::TVec< T >::resize(), PLearn::TVec< T >::size(), sub_layers, and PLearn::TVec< T >::subVec().

{
    PLASSERT( input.size() == input_size );
    output.resize( output_size );

    for( int i=0 ; i<n_layers ; i++ )
    {
        int begin = init_positions[i];
        int size_i = sub_layers[i]->size;
        Vec sub_input = input.subVec(begin, size_i);
        Vec sub_output = output.subVec(begin, size_i);

        sub_layers[i]->fprop( sub_input, sub_output );
    }
}

Here is the call graph for this function:

void PLearn::RBMMixedLayer::fprop ( const Vec input,
const Vec rbm_bias,
Vec output 
) const [virtual]

forward propagation with provided bias

Reimplemented from PLearn::RBMLayer.

Definition at line 287 of file RBMMixedLayer.cc.

References i, init_positions, PLearn::OnlineLearningModule::input_size, n_layers, PLearn::OnlineLearningModule::output_size, PLASSERT, PLearn::TVec< T >::resize(), PLearn::TVec< T >::size(), sub_layers, and PLearn::TVec< T >::subVec().

{
    PLASSERT( input.size() == input_size );
    PLASSERT( rbm_bias.size() == input_size );
    output.resize( output_size );

    for( int i=0 ; i<n_layers ; i++ )
    {
        int begin = init_positions[i];
        int size_i = sub_layers[i]->size;
        Vec sub_input = input.subVec(begin, size_i);
        Vec sub_rbm_bias = rbm_bias.subVec(begin, size_i);
        Vec sub_output = output.subVec(begin, size_i);

        sub_layers[i]->fprop( sub_input, sub_rbm_bias, sub_output );
    }
}

Here is the call graph for this function:

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

Batch forward propagation.

Reimplemented from PLearn::RBMLayer.

Definition at line 268 of file RBMMixedLayer.cc.

References i, init_positions, PLearn::TMat< T >::length(), n_layers, PLASSERT, PLearn::TMat< T >::resize(), PLearn::TVec< T >::size(), PLearn::RBMLayer::size, sub_layers, PLearn::TMat< T >::subMatColumns(), and PLearn::TMat< T >::width().

{
    int mbatch_size = inputs.length();
    PLASSERT( inputs.width() == size );
    outputs.resize( mbatch_size, size );

    for( int i=0 ; i<n_layers ; i++ )
    {
        int begin = init_positions[i];
        int size_i = sub_layers[i]->size;
        Mat sub_inputs = inputs.subMatColumns(begin, size_i);
        Mat sub_outputs = outputs.subMatColumns(begin, size_i);

        // GCC bug? This doesn't work:
        // sub_layers[i]->fprop( sub_inputs, sub_outputs );
        sub_layers[i]->OnlineLearningModule::fprop( sub_inputs, sub_outputs );
    }
}

Here is the call graph for this function:

real PLearn::RBMMixedLayer::fpropNLL ( const Vec target) [virtual]

Computes the negative log-likelihood of target given the internal activations of the layer.

Reimplemented from PLearn::RBMLayer.

Definition at line 415 of file RBMMixedLayer.cc.

References computeExpectation(), i, init_positions, PLearn::OnlineLearningModule::input_size, n_layers, nlls, PLASSERT, PLearn::TVec< T >::resize(), PLearn::TVec< T >::size(), sub_layers, and PLearn::TVec< T >::subVec().

{
    computeExpectation();

    PLASSERT( target.size() == input_size );
    nlls.resize(n_layers);

    real ret = 0;
    real nlli = 0;
    for( int i=0 ; i<n_layers ; i++ )
    {
        int begin = init_positions[i];
        int size_i = sub_layers[i]->size;
        nlli = sub_layers[i]->fpropNLL( target.subVec(begin, size_i));
        nlls[i] = nlli;
        ret += nlli;
    }
    return ret;
}

Here is the call graph for this function:

void PLearn::RBMMixedLayer::fpropNLL ( const Mat targets,
const Mat costs_column 
) [virtual]

Batch fpropNLL.

Reimplemented from PLearn::RBMLayer.

Definition at line 435 of file RBMMixedLayer.cc.

References PLearn::RBMLayer::batch_size, PLearn::TMat< T >::clear(), PLearn::TMat< T >::column(), computeExpectation(), i, init_positions, PLearn::OnlineLearningModule::input_size, j, PLearn::TMat< T >::length(), mat_nlls, n_layers, PLASSERT, PLearn::TMat< T >::resize(), PLearn::TVec< T >::size(), sub_layers, PLearn::TMat< T >::subMatColumns(), and PLearn::TMat< T >::width().

{
    computeExpectation();

    PLASSERT( targets.width() == input_size );
    PLASSERT( targets.length() == batch_size );
    PLASSERT( costs_column.width() == 1 );
    PLASSERT( costs_column.length() == batch_size );

    costs_column.clear();
    mat_nlls.resize(batch_size, n_layers);
    for( int i=0 ; i<n_layers ; i++ )
    {
        int begin = init_positions[i];
        int size_i = sub_layers[i]->size;
        sub_layers[i]->fpropNLL( targets.subMatColumns(begin, size_i),
                                 mat_nlls.column(i) );
        for( int j=0; j < batch_size; ++j )
            costs_column(j,0) += mat_nlls(j, i);
    }
}

Here is the call graph for this function:

real PLearn::RBMMixedLayer::freeEnergyContribution ( const Vec unit_activations) const [virtual]

Computes $ -log(\sum_{possible values of h} exp(h' unit_activations))$ This quantity is used for computing the free energy of a sample x in the OTHER layer of an RBM, from which unit_activations was computed.

Reimplemented from PLearn::RBMLayer.

Definition at line 727 of file RBMMixedLayer.cc.

References i, init_positions, n_layers, PLearn::TVec< T >::size(), sub_layers, and PLearn::TVec< T >::subVec().

{
    real freeEnergy = 0;

    Vec act;
    for ( int i = 0; i < n_layers; ++i ) {
        int begin = init_positions[i];
        int size_i = sub_layers[i]->size;
        act = unit_activations.subVec( begin, size_i );
        freeEnergy += sub_layers[i]->freeEnergyContribution(act);
    }

    return freeEnergy;
}

Here is the call graph for this function:

void PLearn::RBMMixedLayer::freeEnergyContributionGradient ( const Vec unit_activations,
Vec unit_activations_gradient,
real  output_gradient = 1,
bool  accumulate = false 
) const [virtual]

Computes gradient of the result of freeEnergyContribution $ -log(\sum_{possible values of h} exp(h' unit_activations))$ with respect to unit_activations.

Optionally, a gradient with respect to freeEnergyContribution can be given

Reimplemented from PLearn::RBMLayer.

Definition at line 743 of file RBMMixedLayer.cc.

References i, init_positions, n_layers, PLearn::TVec< T >::size(), sub_layers, and PLearn::TVec< T >::subVec().

{
    Vec act;
    Vec gact;
    for ( int i = 0; i < n_layers; ++i ) {
        int begin = init_positions[i];
        int size_i = sub_layers[i]->size;
        act = unit_activations.subVec( begin, size_i );
        gact = unit_activations_gradient.subVec( begin, size_i );
        sub_layers[i]->freeEnergyContributionGradient(
            act, gact, output_gradient, accumulate);
    }
}

Here is the call graph for this function:

virtual void PLearn::RBMMixedLayer::generateSample ( ) [virtual]

compute a sample, and update the sample field

Implements PLearn::RBMLayer.

void PLearn::RBMMixedLayer::generateSample ( ) [virtual]

compute a sample, and update the sample field

Implements PLearn::RBMLayer.

Definition at line 87 of file DEPRECATED/RBMMixedLayer.cc.

References i, n_layers, and sub_layers.

{
    for( int i=0 ; i<n_layers ; i++ )
        sub_layers[i]->generateSample();
}
void PLearn::RBMMixedLayer::generateSamples ( ) [virtual]

generate activations.length() samples

Implements PLearn::RBMLayer.

Definition at line 212 of file RBMMixedLayer.cc.

References i, n_layers, and sub_layers.

{
    for( int i=0 ; i<n_layers ; i++ )
        sub_layers[i]->generateSamples();
}
void PLearn::RBMMixedLayer::getAllActivations ( PP< RBMConnection rbmc,
int  offset = 0,
bool  minibatch = false 
) [virtual]

Uses "rbmc" to obtain the activations of all units in this layer.

Unit 0 of this layer corresponds to unit "offset" of "rbmc".

Reimplemented from PLearn::RBMLayer.

Definition at line 179 of file RBMMixedLayer.cc.

References PLearn::RBMLayer::getAllActivations(), i, n_layers, and sub_layers.

{
    inherited::getAllActivations( rbmc, offset, minibatch );
    for( int i=0 ; i<n_layers ; i++ )
    {
        if( minibatch )
            sub_layers[i]->expectations_are_up_to_date = false;
        else
            sub_layers[i]->expectation_is_up_to_date = false;
    }
}

Here is the call graph for this function:

void PLearn::RBMMixedLayer::getAllActivations ( PP< RBMParameters rbmp,
int  offset = 0 
) [virtual]

Uses "rbmp" to obtain the activations of all units in this layer.

Unit 0 of this layer corresponds to unit "offset" of "rbmp".

Implements PLearn::RBMLayer.

Definition at line 77 of file DEPRECATED/RBMMixedLayer.cc.

References PLearn::RBMLayer::expectation_is_up_to_date, i, init_positions, n_layers, and sub_layers.

{
    for( int i=0 ; i<n_layers ; i++ )
    {
        int total_offset = offset + init_positions[i];
        sub_layers[i]->getAllActivations( rbmp, total_offset );
    }
    expectation_is_up_to_date = false;
}
void PLearn::RBMMixedLayer::getConfiguration ( int  conf_index,
Vec output 
) [virtual]

Computes the conf_index configuration of the layer.

Reimplemented from PLearn::RBMLayer.

Definition at line 775 of file RBMMixedLayer.cc.

References getConfigurationCount(), i, init_positions, PLearn::TVec< T >::length(), n_layers, PLASSERT, PLearn::TVec< T >::size(), PLearn::RBMLayer::size, sub_layers, and PLearn::TVec< T >::subVec().

{
    PLASSERT( output.length() == size );
    PLASSERT( conf_index >= 0 && conf_index < getConfigurationCount() );

    int conf_i = conf_index;
    for ( int i = 0; i < n_layers; ++i ) {
        int conf_layer_i = sub_layers[i]->getConfigurationCount();
        int begin = init_positions[i];
        int size_i = sub_layers[i]->size;
        Vec output_i = output.subVec( begin, size_i );
        sub_layers[i]->getConfiguration(conf_i % conf_layer_i, output_i);
        conf_i /= conf_layer_i;
    }
}

Here is the call graph for this function:

int PLearn::RBMMixedLayer::getConfigurationCount ( ) [virtual]

Returns a number of different configurations the layer can be in.

Reimplemented from PLearn::RBMLayer.

Definition at line 760 of file RBMMixedLayer.cc.

References i, PLearn::RBMLayer::INFINITE_CONFIGURATIONS, n_layers, and sub_layers.

Referenced by getConfiguration().

{
    int count = 1;

    for ( int i = 0; i < n_layers; ++i ) {
        int cc_layer_i = sub_layers[i]->getConfigurationCount();
        // Avoiding overflow
        if ( INFINITE_CONFIGURATIONS/cc_layer_i <= count )
            return INFINITE_CONFIGURATIONS;
        count *= cc_layer_i;
    }

    return count;
}

Here is the caller graph for this function:

OptionList & PLearn::RBMMixedLayer::getOptionList ( ) const [virtual]

Reimplemented from PLearn::Object.

Definition at line 49 of file DEPRECATED/RBMMixedLayer.cc.

virtual OptionList& PLearn::RBMMixedLayer::getOptionList ( ) const [virtual]

Reimplemented from PLearn::Object.

virtual OptionMap& PLearn::RBMMixedLayer::getOptionMap ( ) const [virtual]

Reimplemented from PLearn::Object.

OptionMap & PLearn::RBMMixedLayer::getOptionMap ( ) const [virtual]

Reimplemented from PLearn::Object.

Definition at line 49 of file DEPRECATED/RBMMixedLayer.cc.

virtual RemoteMethodMap& PLearn::RBMMixedLayer::getRemoteMethodMap ( ) const [virtual]

Reimplemented from PLearn::Object.

RemoteMethodMap & PLearn::RBMMixedLayer::getRemoteMethodMap ( ) const [virtual]

Reimplemented from PLearn::Object.

Definition at line 49 of file DEPRECATED/RBMMixedLayer.cc.

void PLearn::RBMMixedLayer::getUnitActivation ( int  i,
PP< RBMConnection rbmc,
int  offset = 0 
) [virtual]

Uses "rbmc" to compute the activation of unit "i" of this layer.

This activation is computed by the "i+offset"-th unit of "rbmc"

Reimplemented from PLearn::RBMLayer.

Definition at line 167 of file RBMMixedLayer.cc.

References PLearn::RBMLayer::getUnitActivation(), i, j, layer_of_unit, and sub_layers.

{
    inherited::getUnitActivation( i, rbmc, offset );

    int j = layer_of_unit[i];
    sub_layers[j]->expectation_is_up_to_date = false;
}

Here is the call graph for this function:

void PLearn::RBMMixedLayer::getUnitActivations ( int  i,
PP< RBMParameters rbmp,
int  offset = 0 
) [virtual]

Uses "rbmp" to obtain the activations of unit "i" of this layer.

This activation vector is computed by the "i+offset"-th unit of "rbmp"

Implements PLearn::RBMLayer.

Definition at line 63 of file DEPRECATED/RBMMixedLayer.cc.

References PLearn::RBMLayer::expectation_is_up_to_date, i, init_positions, j, layer_of_unit, and sub_layers.

{
    int j = layer_of_unit[i];
    PP<RBMLayer> layer = sub_layers[i];
    int sub_index = i - init_positions[j];
    int total_offset = offset + init_positions[j];

    layer->getUnitActivations( sub_index, rbmp, total_offset );
    expectation_is_up_to_date = false;
}
void PLearn::RBMMixedLayer::makeDeepCopyFromShallowCopy ( CopiesMap copies) [virtual]

Transforms a shallow copy into a deep copy.

Reimplemented from PLearn::RBMLayer.

Definition at line 169 of file DEPRECATED/RBMMixedLayer.cc.

References PLearn::deepCopyField(), init_positions, layer_of_unit, PLearn::RBMLayer::makeDeepCopyFromShallowCopy(), and sub_layers.

Here is the call graph for this function:

virtual void PLearn::RBMMixedLayer::makeDeepCopyFromShallowCopy ( CopiesMap copies) [virtual]

Transforms a shallow copy into a deep copy.

Reimplemented from PLearn::RBMLayer.

void PLearn::RBMMixedLayer::reset ( ) [virtual]

resets activations, sample and expectation fields

Reimplemented from PLearn::RBMLayer.

Definition at line 590 of file RBMMixedLayer.cc.

References PLearn::RBMLayer::expectation_is_up_to_date, i, n_layers, and sub_layers.

{
    for( int i=0 ; i<n_layers ; i++ )
        sub_layers[i]->reset();

    expectation_is_up_to_date = false;
}
void PLearn::RBMMixedLayer::setBatchSize ( int  the_batch_size) [virtual]

Sets batch_size and resize activations, expectations, and samples.

Reimplemented from PLearn::RBMLayer.

Definition at line 89 of file RBMMixedLayer.cc.

References i, n_layers, PLearn::RBMLayer::setBatchSize(), and sub_layers.

Referenced by setExpectations(), and setExpectationsByRef().

{
    inherited::setBatchSize( the_batch_size );
    for( int i = 0; i < n_layers; i++ )
        sub_layers[i]->setBatchSize( the_batch_size );
}

Here is the call graph for this function:

Here is the caller graph for this function:

void PLearn::RBMMixedLayer::setExpectation ( const Vec the_expectation) [virtual]

Copy the given expectation in the 'expectation' vector.

Reimplemented from PLearn::RBMLayer.

Definition at line 99 of file RBMMixedLayer.cc.

References PLearn::RBMLayer::expectation, PLearn::RBMLayer::expectation_is_up_to_date, i, n_layers, and sub_layers.

{
    expectation << the_expectation;
    expectation_is_up_to_date=true;
    for( int i = 0; i < n_layers; i++ )
        sub_layers[i]->expectation_is_up_to_date=true;
}
void PLearn::RBMMixedLayer::setExpectationByRef ( const Vec the_expectation) [virtual]

Make the 'expectation' vector point to the given data vector (so no copy is performed).

Reimplemented from PLearn::RBMLayer.

Definition at line 110 of file RBMMixedLayer.cc.

References PLearn::RBMLayer::expectation, PLearn::RBMLayer::expectation_is_up_to_date, i, init_positions, n_layers, sub_layers, and PLearn::TVec< T >::subVec().

{
    expectation = the_expectation;
    expectation_is_up_to_date=true;

     // Rearrange pointers
    for( int i = 0; i < n_layers; i++ )
    {
        int init_pos = init_positions[i];
        PP<RBMLayer> layer = sub_layers[i];
        int layer_size = layer->size;

        layer->setExpectationByRef( expectation.subVec(init_pos, layer_size) );
    }

}

Here is the call graph for this function:

void PLearn::RBMMixedLayer::setExpectations ( const Mat the_expectations) [virtual]

Copy the given expectations in the 'expectations' matrix.

Reimplemented from PLearn::RBMLayer.

Definition at line 130 of file RBMMixedLayer.cc.

References PLearn::RBMLayer::batch_size, PLearn::RBMLayer::expectations, PLearn::RBMLayer::expectations_are_up_to_date, i, PLearn::TMat< T >::length(), n_layers, setBatchSize(), and sub_layers.

{
    batch_size = the_expectations.length();
    setBatchSize( batch_size );
    expectations << the_expectations;
    expectations_are_up_to_date=true;
    for( int i = 0; i < n_layers; i++ )
        sub_layers[i]->expectations_are_up_to_date=true;
}

Here is the call graph for this function:

void PLearn::RBMMixedLayer::setExpectationsByRef ( const Mat the_expectations) [virtual]

Make the 'expectations' matrix point to the given data matrix (so no copy is performed).

Reimplemented from PLearn::RBMLayer.

Definition at line 143 of file RBMMixedLayer.cc.

References PLearn::RBMLayer::batch_size, PLearn::RBMLayer::expectations, PLearn::RBMLayer::expectations_are_up_to_date, i, init_positions, PLearn::TMat< T >::length(), n_layers, setBatchSize(), sub_layers, and PLearn::TMat< T >::subMatColumns().

{
    batch_size = the_expectations.length();
    setBatchSize( batch_size );
    expectations = the_expectations;
    expectations_are_up_to_date=true;

    // Rearrange pointers
    for( int i = 0; i < n_layers; i++ )
    {
        int init_pos = init_positions[i];
        PP<RBMLayer> layer = sub_layers[i];
        int layer_size = layer->size;

        layer->setExpectationsByRef(expectations.subMatColumns(init_pos,
                                                              layer_size));
    }
}

Here is the call graph for this function:

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

Sets the learning rate, also in the sub_layers.

Reimplemented from PLearn::RBMLayer.

Definition at line 67 of file RBMMixedLayer.cc.

References i, n_layers, PLearn::RBMLayer::setLearningRate(), and sub_layers.

{
    inherited::setLearningRate( the_learning_rate );

    for( int i=0 ; i<n_layers ; i++ )
        sub_layers[i]->setLearningRate( the_learning_rate );
}

Here is the call graph for this function:

void PLearn::RBMMixedLayer::setMomentum ( real  the_momentum) [virtual]

Sets the momentum, also in the sub_layers.

Reimplemented from PLearn::RBMLayer.

Definition at line 78 of file RBMMixedLayer.cc.

References i, n_layers, PLearn::RBMLayer::setMomentum(), and sub_layers.

{
    inherited::setMomentum( the_momentum );

    for( int i=0 ; i<n_layers ; i++ )
        sub_layers[i]->setMomentum( the_momentum );
}

Here is the call graph for this function:

void PLearn::RBMMixedLayer::update ( const Vec pos_values,
const Vec neg_values 
) [virtual]

Update parameters according to one pair of vectors.

Reimplemented from PLearn::RBMLayer.

Definition at line 564 of file RBMMixedLayer.cc.

References i, init_positions, n_layers, PLearn::TVec< T >::size(), sub_layers, and PLearn::TVec< T >::subVec().

{
    for( int i=0 ; i<n_layers ; i++ )
    {
        int begin = init_positions[i];
        int size_i = sub_layers[i]->size;
        Vec sub_pos_values = pos_values.subVec( begin, size_i );
        Vec sub_neg_values = neg_values.subVec( begin, size_i );

        sub_layers[i]->update( sub_pos_values, sub_neg_values );
    }
}

Here is the call graph for this function:

void PLearn::RBMMixedLayer::update ( const Mat pos_values,
const Mat neg_values 
) [virtual]

Update parameters according to several pairs of vectors.

Reimplemented from PLearn::RBMLayer.

Definition at line 577 of file RBMMixedLayer.cc.

References i, init_positions, n_layers, PLearn::TVec< T >::size(), sub_layers, and PLearn::TMat< T >::subMatColumns().

{
    for( int i=0 ; i<n_layers ; i++ )
    {
        int begin = init_positions[i];
        int size_i = sub_layers[i]->size;
        Mat sub_pos_values = pos_values.subMatColumns( begin, size_i );
        Mat sub_neg_values = neg_values.subMatColumns( begin, size_i );

        sub_layers[i]->update( sub_pos_values, sub_neg_values );
    }
}

Here is the call graph for this function:

void PLearn::RBMMixedLayer::update ( ) [virtual]

Update parameters according to accumulated statistics.

Reimplemented from PLearn::RBMLayer.

Definition at line 556 of file RBMMixedLayer.cc.

References clearStats(), i, n_layers, and sub_layers.

{
    for( int i=0 ; i<n_layers ; i++ )
        sub_layers[i]->update();

    clearStats();
}

Here is the call graph for this function:


Member Data Documentation

Reimplemented from PLearn::RBMLayer.

Definition at line 99 of file DEPRECATED/RBMMixedLayer.h.

layer_of_unit[i] is the index of sub_layer containing unit i

Definition at line 113 of file DEPRECATED/RBMMixedLayer.h.

Referenced by build_(), declareOptions(), getUnitActivation(), getUnitActivations(), and makeDeepCopyFromShallowCopy().

Definition at line 249 of file RBMMixedLayer.h.

Referenced by bpropNLL(), and fpropNLL().

Vec PLearn::RBMMixedLayer::nlls [mutable, private]

Definition at line 248 of file RBMMixedLayer.h.

Referenced by bpropNLL(), and fpropNLL().


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