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

RBM to be used when doing joint supervised learning by CD. More...

#include <InferenceRBM.h>

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

List of all members.

Public Member Functions

 InferenceRBM ()
 Default constructor.
void hiddenExpGivenVisible (const Mat &visible)
void hiddenExpGivenInputTarget (const Mat &input, const TVec< int > &target)
void hiddenExpGivenInput (const Mat &input)
void targetExpGivenInput (const Mat &input)
Mat getHiddenExpGivenVisible (const Mat &visible)
Mat getHiddenExpGivenInputTarget (const Mat &input, const TVec< int > &target)
Mat getHiddenExpGivenInput (const Mat &input)
Mat getTargetExpGivenInput (const Mat &input)
void supCDStep (const Mat &visible)
void unsupCDStep (const Mat &input)
virtual void setLearningRate (real the_learning_rate)
virtual string classname () const
virtual OptionListgetOptionList () const
virtual OptionMapgetOptionMap () const
virtual RemoteMethodMapgetRemoteMethodMap () const
virtual InferenceRBMdeepCopy (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 ()

Public Attributes

PP< RBMLayerinput_layer
 ### declare public option fields (such as build options) here Input layer (part of visible)
PP< RBMMultinomialLayertarget_layer
 Target layer (other part of visible)
PP< RBMBinomialLayerhidden_layer
 Hidden.
PP< RBMMatrixConnectioninput_to_hidden
 Connection between input and hidden.
PP< RBMMatrixConnectiontarget_to_hidden
 Connection between target and hidden.
string exp_method
 How to compute hidden and target expectation given input Possible values are:
int n_gibbs_steps
 Number of Gibbs steps to use if exp_method=="gibbs".
PP< PRandomrandom_gen
 Random numbers generator.
bool use_fast_approximations
 Whether to use fast approximations in softplus computation.

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 class methods.

Protected Attributes

PP< RBMMixedLayervisible_layer
 Visible layer (concatenation of input and target)
PP< RBMMixedConnectionvisible_to_hidden
int input_size
 Size of input layer.
int target_size
 Size of target layer.
int visible_size
 Size of visible layer.
int hidden_size
 Size of hidden layer.

Private Types

typedef Object inherited

Private Member Functions

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

Private Attributes

Mat v0
Mat h0

Detailed Description

RBM to be used when doing joint supervised learning by CD.

We have input, target and hidden layer. We can compute hidden given (input, target), target given input, or hidden given input.

Todo:
Write class to-do's here if there are any.

Definition at line 60 of file InferenceRBM.h.


Member Typedef Documentation

Reimplemented from PLearn::Object.

Definition at line 62 of file InferenceRBM.h.


Constructor & Destructor Documentation

PLearn::InferenceRBM::InferenceRBM ( )

Default constructor.

Definition at line 56 of file InferenceRBM.cc.


Member Function Documentation

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

Reimplemented from PLearn::Object.

Definition at line 54 of file InferenceRBM.cc.

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

Reimplemented from PLearn::Object.

Definition at line 54 of file InferenceRBM.cc.

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

Reimplemented from PLearn::Object.

Definition at line 54 of file InferenceRBM.cc.

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

Reimplemented from PLearn::Object.

Definition at line 54 of file InferenceRBM.cc.

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

Reimplemented from PLearn::Object.

Definition at line 54 of file InferenceRBM.cc.

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

Reimplemented from PLearn::Object.

Definition at line 54 of file InferenceRBM.cc.

void PLearn::InferenceRBM::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::Object.

Definition at line 66 of file InferenceRBM.cc.

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

Here is the call graph for this function:

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

This does the actual building.

Check (and set) sizes

Build visible layer

Build visible_to_hidden connection

If we have a random_gen, share it with the ones who do not

Reimplemented from PLearn::Object.

Definition at line 247 of file InferenceRBM.cc.

References PLearn::endl(), hidden_layer, hidden_size, input_layer, input_size, input_to_hidden, PLearn::PP< T >::isNull(), PLASSERT, random_gen, target_layer, target_size, target_to_hidden, visible_layer, visible_size, and visible_to_hidden.

Referenced by build().

{
    MODULE_LOG << "build_() called" << endl;

    if( !input_layer || !target_layer || !hidden_layer
        || !input_to_hidden || !target_to_hidden )
    {
        MODULE_LOG << "build_() aborted because layers and connections were"
            " not set" << endl;
        return;
    }

    input_size = input_layer->size;
    target_size = target_layer->size;
    visible_size = input_size + target_size;
    hidden_size = hidden_layer->size;

    PLASSERT(input_to_hidden->down_size == input_size);
    PLASSERT(input_to_hidden->up_size == hidden_size);
    PLASSERT(target_to_hidden->down_size == target_size);
    PLASSERT(target_to_hidden->up_size == hidden_size);

    visible_layer = new RBMMixedLayer();
    visible_layer->sub_layers.resize(2);
    visible_layer->sub_layers[0] = input_layer;
    visible_layer->sub_layers[1] = target_layer;
    visible_layer->build();
    PLASSERT(visible_layer->size == visible_size);

    visible_to_hidden = new RBMMixedConnection();
    visible_to_hidden->sub_connections.resize(1,2);
    visible_to_hidden->sub_connections(0,0) = input_to_hidden;
    visible_to_hidden->sub_connections(0,1) = target_to_hidden;
    visible_to_hidden->build();
    PLASSERT(visible_to_hidden->down_size == visible_size);
    PLASSERT(visible_to_hidden->up_size == hidden_size);

    if (random_gen)
    {
       if (input_layer->random_gen.isNull())
       {
           input_layer->random_gen = random_gen;
           input_layer->forget();
       }
       if (target_layer->random_gen.isNull())
       {
           target_layer->random_gen = random_gen;
           target_layer->forget();
       }
       if (visible_layer->random_gen.isNull())
       {
           visible_layer->random_gen = random_gen;
           visible_layer->forget();
       }
       if (hidden_layer->random_gen.isNull())
       {
           hidden_layer->random_gen = random_gen;
           hidden_layer->forget();
       }
       if (input_to_hidden->random_gen.isNull())
       {
           input_to_hidden->random_gen = random_gen;
           input_to_hidden->forget();
       }
       if (target_to_hidden->random_gen.isNull())
       {
           target_to_hidden->random_gen = random_gen;
           target_to_hidden->forget();
       }
       if (visible_to_hidden->random_gen.isNull())
       {
           visible_to_hidden->random_gen = random_gen;
           visible_to_hidden->forget();
       }
    }

}

Here is the call graph for this function:

Here is the caller graph for this function:

void PLearn::InferenceRBM::build_rbms ( ) [private]
string PLearn::InferenceRBM::classname ( ) const [virtual]

Reimplemented from PLearn::Object.

Definition at line 54 of file InferenceRBM.cc.

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

Declares the class methods.

Reimplemented from PLearn::Object.

Definition at line 173 of file InferenceRBM.cc.

References PLearn::Object::_getRemoteMethodMap_(), PLearn::declareMethod(), getHiddenExpGivenInput(), getHiddenExpGivenInputTarget(), getHiddenExpGivenVisible(), getTargetExpGivenInput(), hiddenExpGivenInput(), hiddenExpGivenInputTarget(), hiddenExpGivenVisible(), PLearn::RemoteMethodMap::inherited(), setLearningRate(), supCDStep(), and targetExpGivenInput().

{
    // Insert a backpointer to remote methods; note that this
    // different than for declareOptions()
    rmm.inherited(inherited::_getRemoteMethodMap_());

    declareMethod(
        rmm, "hiddenExpGivenVisible",
        &InferenceRBM::hiddenExpGivenVisible,
        (BodyDoc("Computes the hidden layer's expectation given the visible"),
         ArgDoc ("visible", "Visible layer's values")));

    declareMethod(
        rmm, "hiddenExpGivenInput",
        &InferenceRBM::hiddenExpGivenInput,
        (BodyDoc("Computes the hidden layer's expectation given the input"),
         ArgDoc ("input", "Input layer's values")));

    declareMethod(
        rmm, "hiddenExpGivenInputTarget",
        &InferenceRBM::hiddenExpGivenInputTarget,
        (BodyDoc("Computes the hidden layer's expectation given the input\n"
                 "and the target"),
         ArgDoc ("input", "Input layer's values"),
         ArgDoc ("target", "Target (as an index)")));

    declareMethod(
        rmm, "targetExpGivenInput",
        &InferenceRBM::targetExpGivenInput,
        (BodyDoc("Computes the target layer's expectation given the input"),
         ArgDoc ("input", "Input layer's values")));

    declareMethod(
        rmm, "getHiddenExpGivenVisible",
        &InferenceRBM::getHiddenExpGivenVisible,
        (BodyDoc("Computes the hidden layer's expectation given the visible"),
         ArgDoc ("visible", "Visible layer's values"),
         RetDoc ("Hidden layer's expectation")));

    declareMethod(
        rmm, "getHiddenExpGivenInput",
        &InferenceRBM::getHiddenExpGivenInput,
        (BodyDoc("Computes the hidden layer's expectation given the input"),
         ArgDoc ("input", "Input layer's values"),
         RetDoc ("Hidden layer's expectation")));

    declareMethod(
        rmm, "getHiddenExpGivenInputTarget",
        &InferenceRBM::getHiddenExpGivenInputTarget,
        (BodyDoc("Computes the hidden layer's expectation given the input\n"
                 "and the target"),
         ArgDoc ("input", "Input layer's values"),
         ArgDoc ("target", "Target (as an index)"),
         RetDoc ("Hidden layer's expectation")));

    declareMethod(
        rmm, "getTargetExpGivenInput",
        &InferenceRBM::getTargetExpGivenInput,
        (BodyDoc("Computes the target layer's expectation given the input"),
         ArgDoc ("input", "Input layer's values"),
         RetDoc ("Target layer's expectation")));

    declareMethod(
        rmm, "supCDStep", &InferenceRBM::supCDStep,
        (BodyDoc("Performs one step of CD and updates the parameters"),
         ArgDoc ("visible", "Visible layer's values")));

    declareMethod(
        rmm, "setLearningRate", &InferenceRBM::setLearningRate,
        (BodyDoc("Sets the learning rate of underlying modules"),
         ArgDoc ("the_learning_rate", "The learning rate")));
}

Here is the call graph for this function:

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

Declares the class options.

Reimplemented from PLearn::Object.

Definition at line 91 of file InferenceRBM.cc.

References PLearn::OptionBase::buildoption, PLearn::declareOption(), PLearn::Object::declareOptions(), exp_method, hidden_layer, hidden_size, input_layer, input_size, input_to_hidden, PLearn::OptionBase::learntoption, n_gibbs_steps, random_gen, target_layer, target_size, target_to_hidden, use_fast_approximations, visible_layer, visible_size, and visible_to_hidden.

{
    // declareOption(ol, "myoption", &InferenceRBM::myoption,
    //               OptionBase::buildoption,
    //               "Help text describing this option");


    declareOption(ol, "input_layer", &InferenceRBM::input_layer,
                  OptionBase::buildoption,
                  "Input layer (part of visible)");

    declareOption(ol, "target_layer", &InferenceRBM::target_layer,
                  OptionBase::buildoption,
                  "Target layer (part of visible)");

    declareOption(ol, "hidden_layer", &InferenceRBM::hidden_layer,
                  OptionBase::buildoption,
                  "Hidden layer");

    declareOption(ol, "input_to_hidden", &InferenceRBM::input_to_hidden,
                  OptionBase::buildoption,
                  "Connection between input and hidden layers");

    declareOption(ol, "target_to_hidden", &InferenceRBM::target_to_hidden,
                  OptionBase::buildoption,
                  "Connection between target and hidden layers");

    declareOption(ol, "exp_method", &InferenceRBM::exp_method,
                  OptionBase::buildoption,
                  "How to compute hidden and target expectation given input.\n"
                  "Possible values are:\n"
                  "    - \"exact\": exact inference, O(target_size), default\n"
                  "    - \"gibbs\": estimation by Gibbs sampling\n"
                  );

    declareOption(ol, "n_gibbs_steps", &InferenceRBM::n_gibbs_steps,
                  OptionBase::buildoption,
                  "Number of Gibbs steps to use if exp_method==\"gibbs\"");

    declareOption(ol, "random_gen", &InferenceRBM::random_gen,
                  OptionBase::buildoption,
                  "Random numbers generator");

    declareOption(ol, "use_fast_approximations",
                  &InferenceRBM::use_fast_approximations,
                  OptionBase::buildoption,
                  "Whether to use fast approximations in softplus computation");


    declareOption(ol, "visible_layer", &InferenceRBM::visible_layer,
                  OptionBase::learntoption,
                  "Visible layer (input+target)");

    declareOption(ol, "visible_to_hidden", &InferenceRBM::visible_to_hidden,
                  OptionBase::learntoption,
                  "Connection between visible and hidden layers");

    declareOption(ol, "input_size", &InferenceRBM::input_size,
                  OptionBase::learntoption,
                  "Size of input_layer");

    declareOption(ol, "target_size", &InferenceRBM::target_size,
                  OptionBase::learntoption,
                  "Size of target_layer");

    declareOption(ol, "visible_size", &InferenceRBM::visible_size,
                  OptionBase::learntoption,
                  "Size of visible_layer");

    declareOption(ol, "hidden_size", &InferenceRBM::hidden_size,
                  OptionBase::learntoption,
                  "Size of hidden_layer");


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

Here is the call graph for this function:

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

Reimplemented from PLearn::Object.

Definition at line 128 of file InferenceRBM.h.

:
    //#####  Protected Options  ###############################################
InferenceRBM * PLearn::InferenceRBM::deepCopy ( CopiesMap copies) const [virtual]

Reimplemented from PLearn::Object.

Definition at line 54 of file InferenceRBM.cc.

Mat PLearn::InferenceRBM::getHiddenExpGivenInput ( const Mat input)

Definition at line 450 of file InferenceRBM.cc.

References hidden_layer, and hiddenExpGivenInput().

Referenced by declareMethods().

{
    hiddenExpGivenInput(input);
    return hidden_layer->getExpectations();
}

Here is the call graph for this function:

Here is the caller graph for this function:

Mat PLearn::InferenceRBM::getHiddenExpGivenInputTarget ( const Mat input,
const TVec< int > &  target 
)

Definition at line 437 of file InferenceRBM.cc.

References hidden_layer, and hiddenExpGivenInputTarget().

Referenced by declareMethods().

{
    hiddenExpGivenInputTarget(input, target);
    return hidden_layer->getExpectations();
}

Here is the call graph for this function:

Here is the caller graph for this function:

Mat PLearn::InferenceRBM::getHiddenExpGivenVisible ( const Mat visible)

Definition at line 431 of file InferenceRBM.cc.

References hidden_layer, and hiddenExpGivenVisible().

Referenced by declareMethods().

{
    hiddenExpGivenVisible(visible);
    return hidden_layer->getExpectations();
}

Here is the call graph for this function:

Here is the caller graph for this function:

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

Reimplemented from PLearn::Object.

Definition at line 54 of file InferenceRBM.cc.

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

Reimplemented from PLearn::Object.

Definition at line 54 of file InferenceRBM.cc.

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

Reimplemented from PLearn::Object.

Definition at line 54 of file InferenceRBM.cc.

Mat PLearn::InferenceRBM::getTargetExpGivenInput ( const Mat input)

Definition at line 444 of file InferenceRBM.cc.

References target_layer, and targetExpGivenInput().

Referenced by declareMethods().

{
    targetExpGivenInput(input);
    return target_layer->getExpectations();
}

Here is the call graph for this function:

Here is the caller graph for this function:

void PLearn::InferenceRBM::hiddenExpGivenInput ( const Mat input)

Definition at line 404 of file InferenceRBM.cc.

References PLearn::TMat< T >::clear(), PLearn::TMat< T >::column(), PLearn::TMat< T >::fill(), hidden_layer, hidden_size, hiddenExpGivenVisible(), i, input_size, PLearn::TMat< T >::length(), PLASSERT, PLearn::TMat< T >::subMatColumns(), target_layer, target_size, targetExpGivenInput(), visible_size, and PLearn::TMat< T >::width().

Referenced by declareMethods(), and getHiddenExpGivenInput().

{
    PLASSERT(input.width() == input_size);
    int batch_size = input.length();

    targetExpGivenInput(input);
    Mat target_exp = target_layer->getExpectations();

    Mat visible(batch_size, visible_size);
    visible.subMatColumns(0, input_size) << input;

    Mat hidden_exp(batch_size, hidden_size);

    for (int i=0; i<target_size; i++)
    {
        visible.subMatColumns(input_size, target_size).clear();
        visible.column(input_size+i).fill(1.);

        hiddenExpGivenVisible(visible);

        for (int k=0; k<batch_size; k++)
            hidden_exp(k) += target_exp(k,i) * hidden_layer->getExpectations()(k);
    }

    hidden_layer->setExpectations(hidden_exp);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void PLearn::InferenceRBM::hiddenExpGivenInputTarget ( const Mat input,
const TVec< int > &  target 
)

Definition at line 338 of file InferenceRBM.cc.

References PLearn::get_pointer(), hidden_layer, input_size, input_to_hidden, PLearn::TMat< T >::length(), PLearn::TVec< T >::length(), PLASSERT, target_to_hidden, and PLearn::TMat< T >::width().

Referenced by declareMethods(), and getHiddenExpGivenInputTarget().

{
    int batch_size = input.length();
    PLASSERT(input.width() == input_size);
    PLASSERT(target.length() == batch_size);

    input_to_hidden->setAsDownInputs(input);
    hidden_layer->getAllActivations(get_pointer(input_to_hidden), 0, true);

    for (int k=0; k<batch_size; k++)
        hidden_layer->activations(k) += target_to_hidden->weights(target[k]);

    hidden_layer->expectations_are_up_to_date = false;
    hidden_layer->computeExpectations();
}

Here is the call graph for this function:

Here is the caller graph for this function:

void PLearn::InferenceRBM::hiddenExpGivenVisible ( const Mat visible)

Definition at line 329 of file InferenceRBM.cc.

References PLearn::get_pointer(), hidden_layer, PLASSERT, visible_size, visible_to_hidden, and PLearn::TMat< T >::width().

Referenced by declareMethods(), getHiddenExpGivenVisible(), hiddenExpGivenInput(), and supCDStep().

{
    PLASSERT(visible.width() == visible_size);

    visible_to_hidden->setAsDownInputs(visible);
    hidden_layer->getAllActivations(get_pointer(visible_to_hidden), 0, true);
    hidden_layer->computeExpectations();
}

Here is the call graph for this function:

Here is the caller graph for this function:

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

Transforms a shallow copy into a deep copy.

Reimplemented from PLearn::Object.

Definition at line 72 of file InferenceRBM.cc.

References PLearn::deepCopyField(), h0, hidden_layer, input_layer, input_to_hidden, PLearn::Object::makeDeepCopyFromShallowCopy(), random_gen, target_layer, target_to_hidden, v0, visible_layer, and visible_to_hidden.

Here is the call graph for this function:

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

Definition at line 490 of file InferenceRBM.cc.

References hidden_layer, visible_layer, and visible_to_hidden.

Referenced by declareMethods().

{
    visible_layer->setLearningRate(the_learning_rate);
    visible_to_hidden->setLearningRate(the_learning_rate);
    hidden_layer->setLearningRate(the_learning_rate);
}

Here is the caller graph for this function:

void PLearn::InferenceRBM::supCDStep ( const Mat visible)

Definition at line 456 of file InferenceRBM.cc.

References PLearn::get_pointer(), h0, hidden_layer, hidden_size, hiddenExpGivenVisible(), PLearn::TMat< T >::length(), PLASSERT, PLearn::TMat< T >::resize(), v0, visible_layer, visible_size, visible_to_hidden, and PLearn::TMat< T >::width().

Referenced by declareMethods().

{
    PLASSERT(visible.width() == visible_size);
    int batch_size = visible.length();

    v0.resize(batch_size,visible_size);
    v0 << visible;

    // positive phase
    hiddenExpGivenVisible(visible);
    h0.resize(batch_size, hidden_size);
    h0 << hidden_layer->getExpectations();

    // Down propagation
    visible_to_hidden->setAsUpInputs(h0);
    visible_layer->getAllActivations(get_pointer(visible_to_hidden), 0, true);
    visible_layer->computeExpectations();
    visible_layer->generateSamples();

    // Negative phase
    hiddenExpGivenVisible(visible_layer->samples);

    // Update
    visible_layer->update(v0, visible_layer->samples);
    visible_to_hidden->update(v0, h0, visible_layer->samples,
                              hidden_layer->getExpectations());
    hidden_layer->update(h0, hidden_layer->getExpectations());
}

Here is the call graph for this function:

Here is the caller graph for this function:

void PLearn::InferenceRBM::targetExpGivenInput ( const Mat input)

Definition at line 355 of file InferenceRBM.cc.

References PLearn::get_pointer(), hidden_layer, hidden_size, i, input_size, input_to_hidden, j, PLearn::TMat< T >::length(), PLASSERT, PLearn::softplus(), PLearn::tabulated_softplus(), target_layer, target_size, target_to_hidden, use_fast_approximations, and PLearn::TMat< T >::width().

Referenced by declareMethods(), getTargetExpGivenInput(), and hiddenExpGivenInput().

{
    PLASSERT(input.width() == input_size);
    int batch_size = input.length();

    // input contains samples (or expectations) from input_layer
    input_to_hidden->setAsDownInputs(input);

    // hidden_layer->activations = bias + input_to_hidden.weights * input
    hidden_layer->getAllActivations(get_pointer(input_to_hidden), 0, true);

    target_layer->setBatchSize(batch_size);

    // target_layer->activations[k][i] =
    //      bias[i] + sum_j softplus(W_ji + hidden_layer->activations[k][j])
    Mat hidden_act = hidden_layer->activations;
    Mat target_act = target_layer->activations;
    Vec target_b = target_layer->bias;
    Mat t_to_h_w = target_to_hidden->weights;

    for (int k=0; k<batch_size; k++)
    {
        target_act(k) << target_b;

        real* target_act_k = target_act[k];
        real* hidden_act_kj = hidden_act[k];
        for (int j=0; j<hidden_size; j++, hidden_act_kj++)
        {
            real* target_act_ki = target_act_k; // copy
            real* t_to_h_w_ji = t_to_h_w[j];
            for (int i=0; i<target_size; i++, target_act_ki++, t_to_h_w_ji++)
            {
                PLASSERT(*target_act_ki == target_act(k,i));
                PLASSERT(*t_to_h_w_ji == t_to_h_w(j,i));
                PLASSERT(*hidden_act_kj == hidden_act(k,j));

                if (use_fast_approximations)
                    *target_act_ki +=
                        tabulated_softplus(*t_to_h_w_ji + *hidden_act_kj);
                else
                    *target_act_ki += softplus(*t_to_h_w_ji + *hidden_act_kj);
            }
        }
    }

    target_layer->expectations_are_up_to_date = false;
    target_layer->computeExpectations();
}

Here is the call graph for this function:

Here is the caller graph for this function:

void PLearn::InferenceRBM::unsupCDStep ( const Mat input)

Definition at line 485 of file InferenceRBM.cc.

References PLCHECK_MSG.

{
    PLCHECK_MSG(false, "Not implemented yet");
}

Member Data Documentation

Reimplemented from PLearn::Object.

Definition at line 128 of file InferenceRBM.h.

How to compute hidden and target expectation given input Possible values are:

  • "exact": exact inference, O(target_size), default
  • "gibbs": estimation by Gibbs sampling

Definition at line 87 of file InferenceRBM.h.

Referenced by declareOptions().

Mat PLearn::InferenceRBM::h0 [mutable, private]

Definition at line 180 of file InferenceRBM.h.

Referenced by makeDeepCopyFromShallowCopy(), and supCDStep().

Size of hidden layer.

Definition at line 156 of file InferenceRBM.h.

Referenced by build_(), declareOptions(), hiddenExpGivenInput(), supCDStep(), and targetExpGivenInput().

### declare public option fields (such as build options) here Input layer (part of visible)

Definition at line 69 of file InferenceRBM.h.

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

Size of input layer.

Definition at line 147 of file InferenceRBM.h.

Referenced by build_(), declareOptions(), hiddenExpGivenInput(), hiddenExpGivenInputTarget(), and targetExpGivenInput().

Connection between input and hidden.

Definition at line 78 of file InferenceRBM.h.

Referenced by build_(), declareOptions(), hiddenExpGivenInputTarget(), makeDeepCopyFromShallowCopy(), and targetExpGivenInput().

Number of Gibbs steps to use if exp_method=="gibbs".

Definition at line 90 of file InferenceRBM.h.

Referenced by declareOptions().

Random numbers generator.

Definition at line 93 of file InferenceRBM.h.

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

Target layer (other part of visible)

Definition at line 72 of file InferenceRBM.h.

Referenced by build_(), declareOptions(), getTargetExpGivenInput(), hiddenExpGivenInput(), makeDeepCopyFromShallowCopy(), and targetExpGivenInput().

Size of target layer.

Definition at line 150 of file InferenceRBM.h.

Referenced by build_(), declareOptions(), hiddenExpGivenInput(), and targetExpGivenInput().

Connection between target and hidden.

Definition at line 81 of file InferenceRBM.h.

Referenced by build_(), declareOptions(), hiddenExpGivenInputTarget(), makeDeepCopyFromShallowCopy(), and targetExpGivenInput().

Whether to use fast approximations in softplus computation.

Definition at line 96 of file InferenceRBM.h.

Referenced by declareOptions(), and targetExpGivenInput().

Mat PLearn::InferenceRBM::v0 [mutable, private]

Definition at line 179 of file InferenceRBM.h.

Referenced by makeDeepCopyFromShallowCopy(), and supCDStep().

Visible layer (concatenation of input and target)

Definition at line 142 of file InferenceRBM.h.

Referenced by build_(), declareOptions(), makeDeepCopyFromShallowCopy(), setLearningRate(), and supCDStep().

Size of visible layer.

Definition at line 153 of file InferenceRBM.h.

Referenced by build_(), declareOptions(), hiddenExpGivenInput(), hiddenExpGivenVisible(), and supCDStep().


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