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

Deep Belief Net, possibly supervised, trained only with CD. More...

#include <SemiSupervisedDBN.h>

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

List of all members.

Public Member Functions

 SemiSupervisedDBN ()
 ### declare public option fields (such as build options) here Start your comments with Doxygen-compatible comments such as //!
virtual int outputsize () const
 Returns the size of this learner's output, (which typically may depend on its inputsize(), targetsize() and set options).
virtual void forget ()
 (Re-)initializes the PLearner in its fresh state (that state may depend on the 'seed' option) and sets 'stage' back to 0 (this is the stage of a fresh learner!).
virtual void train ()
 The role of the train method is to bring the learner up to stage==nstages, updating the train_stats collector with training costs measured on-line in the process.
virtual void computeOutput (const Vec &input, Vec &output) const
 Computes the output from the input.
virtual void computeCostsFromOutputs (const Vec &input, const Vec &output, const Vec &target, Vec &costs) const
 Computes the costs from already computed output.
virtual TVec< std::string > getTestCostNames () const
 Returns the names of the costs computed by computeCostsFromOutpus (and thus the test method).
virtual TVec< std::string > getTrainCostNames () const
 Returns the names of the objective costs that the train method computes and for which it updates the VecStatsCollector train_stats.
virtual string classname () const
virtual OptionListgetOptionList () const
virtual OptionMapgetOptionMap () const
virtual RemoteMethodMapgetRemoteMethodMap () const
virtual SemiSupervisedDBNdeepCopy (CopiesMap &copies) const
virtual void build ()
 Finish building the object; just call inherited::build followed by build_()
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 Public Attributes

static StaticInitializer _static_initializer_

Static Protected Member Functions

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

Private Types

typedef PLearner inherited

Private Member Functions

void build_ ()
 This does the actual building.

Detailed Description

Deep Belief Net, possibly supervised, trained only with CD.

Todo:
Write class to-do's here if there are any.
Deprecated:
Write deprecated stuff here if there is any. Indicate what else should be used instead.

Definition at line 55 of file SemiSupervisedDBN.h.


Member Typedef Documentation

Reimplemented from PLearn::PLearner.

Definition at line 57 of file SemiSupervisedDBN.h.


Constructor & Destructor Documentation

PLearn::SemiSupervisedDBN::SemiSupervisedDBN ( )

### declare public option fields (such as build options) here Start your comments with Doxygen-compatible comments such as //!

Default constructor

Definition at line 50 of file SemiSupervisedDBN.cc.

References PLearn::PLearner::random_gen.

                                    :
    learning_rate(0),
    n_classes(0),
    share_layers(false),
    n_layers(0)
{
    random_gen = new PRandom();
}

Member Function Documentation

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

Reimplemented from PLearn::PLearner.

Definition at line 48 of file SemiSupervisedDBN.cc.

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

Reimplemented from PLearn::PLearner.

Definition at line 48 of file SemiSupervisedDBN.cc.

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

Reimplemented from PLearn::PLearner.

Definition at line 48 of file SemiSupervisedDBN.cc.

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

Reimplemented from PLearn::PLearner.

Definition at line 48 of file SemiSupervisedDBN.cc.

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

Reimplemented from PLearn::Object.

Definition at line 48 of file SemiSupervisedDBN.cc.

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

Reimplemented from PLearn::PLearner.

Definition at line 48 of file SemiSupervisedDBN.cc.

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

Finish building the object; just call inherited::build followed by build_()

Reimplemented from PLearn::PLearner.

Definition at line 140 of file SemiSupervisedDBN.cc.

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

Here is the call graph for this function:

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

This does the actual building.

Reimplemented from PLearn::PLearner.

Definition at line 73 of file SemiSupervisedDBN.cc.

References i.

Referenced by build().

{
    bool rbms_need_build = false;
    if (layer_sizes.length() != rbms.size()+1)
        rbms_need_build = true;
    else
    {
        n_rbms = rbms.size();
        for (int i=0; i<n_rbms; i++)
        {
            if (layer_sizes[i] != rbms[i]->input_size)
            {
                rbms_need_build = true;
                break;
            }
            if (layer_is_supervised[i] && (rbms[i]->target_size != n_target))
            {
                rbms_need_build = true;
                break;
            }
            if (!layer_is_supervised[i] && (rbms[i]->target_size != 0))
            {
                rbms_need_build = true;
                break;
            }
            if (layer_sizes[i+1] != rbms[i]->hidden_size)
            {
                rbms_need_build = true;
                break;
            }
        }
    }

    if (rbms_need_build)
        build_rbms();
}

Here is the caller graph for this function:

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

Reimplemented from PLearn::Object.

Definition at line 48 of file SemiSupervisedDBN.cc.

void PLearn::SemiSupervisedDBN::computeCostsFromOutputs ( const Vec input,
const Vec output,
const Vec target,
Vec costs 
) const [virtual]

Computes the costs from already computed output.

Implements PLearn::PLearner.

Definition at line 227 of file SemiSupervisedDBN.cc.

{
// Compute the costs from *already* computed output.
// ...
}
void PLearn::SemiSupervisedDBN::computeOutput ( const Vec input,
Vec output 
) const [virtual]

Computes the output from the input.

Reimplemented from PLearn::PLearner.

Definition at line 219 of file SemiSupervisedDBN.cc.

{
    // Compute the output from the input.
    // int nout = outputsize();
    // output.resize(nout);
    // ...
}
void PLearn::SemiSupervisedDBN::declareOptions ( OptionList ol) [static, protected]

Declares the class options.

Reimplemented from PLearn::PLearner.

Definition at line 59 of file SemiSupervisedDBN.cc.

References PLearn::OptionBase::buildoption, PLearn::declareOption(), and PLearn::PLearner::declareOptions().

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

    declareOption(ol, "", &SemiSupervisedDBN::,
                  OptionBase::buildoption,
                  "");

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

Here is the call graph for this function:

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

Reimplemented from PLearn::PLearner.

Definition at line 134 of file SemiSupervisedDBN.h.

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

Reimplemented from PLearn::PLearner.

Definition at line 48 of file SemiSupervisedDBN.cc.

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

(Re-)initializes the PLearner in its fresh state (that state may depend on the 'seed' option) and sets 'stage' back to 0 (this is the stage of a fresh learner!).

(Re-)initialize the PLearner in its fresh state (that state may depend on the 'seed' option) and sets 'stage' back to 0 (this is the stage of a fresh learner!)

A typical forget() method should do the following:

  • call inherited::forget() to initialize its random number generator with the 'seed' option
  • initialize the learner's parameters, using this random generator
  • stage = 0

Reimplemented from PLearn::PLearner.

Definition at line 168 of file SemiSupervisedDBN.cc.

References PLearn::PLearner::forget().

Here is the call graph for this function:

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

Reimplemented from PLearn::Object.

Definition at line 48 of file SemiSupervisedDBN.cc.

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

Reimplemented from PLearn::Object.

Definition at line 48 of file SemiSupervisedDBN.cc.

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

Reimplemented from PLearn::Object.

Definition at line 48 of file SemiSupervisedDBN.cc.

TVec< string > PLearn::SemiSupervisedDBN::getTestCostNames ( ) const [virtual]

Returns the names of the costs computed by computeCostsFromOutpus (and thus the test method).

Implements PLearn::PLearner.

Definition at line 234 of file SemiSupervisedDBN.cc.

{
    // Return the names of the costs computed by computeCostsFromOutputs
    // (these may or may not be exactly the same as what's returned by
    // getTrainCostNames).
    // ...
}
TVec< string > PLearn::SemiSupervisedDBN::getTrainCostNames ( ) const [virtual]

Returns the names of the objective costs that the train method computes and for which it updates the VecStatsCollector train_stats.

Implements PLearn::PLearner.

Definition at line 242 of file SemiSupervisedDBN.cc.

{
    // Return the names of the objective costs that the train method computes
    // and for which it updates the VecStatsCollector train_stats
    // (these may or may not be exactly the same as what's returned by
    // getTestCostNames).
    // ...
}
void PLearn::SemiSupervisedDBN::makeDeepCopyFromShallowCopy ( CopiesMap copies) [virtual]

Transforms a shallow copy into a deep copy.

Reimplemented from PLearn::PLearner.

Definition at line 147 of file SemiSupervisedDBN.cc.

References PLearn::PLearner::makeDeepCopyFromShallowCopy(), and PLERROR.

{
    inherited::makeDeepCopyFromShallowCopy(copies);

    // ### Call deepCopyField on all "pointer-like" fields
    // ### that you wish to be deepCopied rather than
    // ### shallow-copied.
    // ### ex:
    // deepCopyField(trainvec, copies);

    // ### Remove this line when you have fully implemented this method.
    PLERROR("SemiSupervisedDBN::makeDeepCopyFromShallowCopy not fully (correctly) implemented yet!");
}

Here is the call graph for this function:

int PLearn::SemiSupervisedDBN::outputsize ( ) const [virtual]

Returns the size of this learner's output, (which typically may depend on its inputsize(), targetsize() and set options).

Implements PLearn::PLearner.

Definition at line 162 of file SemiSupervisedDBN.cc.

{
    // Compute and return the size of this learner's output (which typically
    // may depend on its inputsize(), targetsize() and set options).
}
void PLearn::SemiSupervisedDBN::train ( ) [virtual]

The role of the train method is to bring the learner up to stage==nstages, updating the train_stats collector with training costs measured on-line in the process.

Implements PLearn::PLearner.

Definition at line 183 of file SemiSupervisedDBN.cc.

{
    // The role of the train method is to bring the learner up to
    // stage==nstages, updating train_stats with training costs measured
    // on-line in the process.

    /* TYPICAL CODE:

    static Vec input;  // static so we don't reallocate memory each time...
    static Vec target; // (but be careful that static means shared!)
    input.resize(inputsize());    // the train_set's inputsize()
    target.resize(targetsize());  // the train_set's targetsize()
    real weight;

    // This generic PLearner method does a number of standard stuff useful for
    // (almost) any learner, and return 'false' if no training should take
    // place. See PLearner.h for more details.
    if (!initTrain())
        return;

    while(stage<nstages)
    {
        // clear statistics of previous epoch
        train_stats->forget();

        //... train for 1 stage, and update train_stats,
        // using train_set->getExample(input, target, weight)
        // and train_stats->update(train_costs)

        ++stage;
        train_stats->finalize(); // finalize statistics for this epoch
    }
    */
}

Member Data Documentation

Reimplemented from PLearn::PLearner.

Definition at line 134 of file SemiSupervisedDBN.h.


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