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

The first sentence should be a BRIEF DESCRIPTION of what the class does. More...

#include <RBMTrainer.h>

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

List of all members.

Public Member Functions

 RBMTrainer ()
 Default constructor.
Mat NLL (const Mat &examples)
Mat recError (const Mat &examples)
void CD1 (const Mat &examples)
virtual void run ()
 Override this for runnable objects (default method issues a runtime error).
virtual string classname () const
virtual OptionListgetOptionList () const
virtual OptionMapgetOptionMap () const
virtual RemoteMethodMapgetRemoteMethodMap () const
virtual RBMTrainerdeepCopy (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

int n_visible
 ### declare public option fields (such as build options) here Start your comments with Doxygen-compatible comments such as //!
int n_hidden
string visible_type
bool update_with_h0_sample
bool sample_v1_in_chain
bool compute_log_likelihood
int n_stages
real learning_rate
int32_t seed
int n_train
int n_valid
int n_test
int batch_size
PPath data_filename
PPath save_path
PPath save_name
bool print_debug
bool use_fast_approximations

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)
 Declare methods that are intended to be remote-callable.

Protected Attributes

VMat data
VMat train_input
VMat valid_input
VMat test_input
PP< RBMModulerbm
PP< RBMLayervisible
PP< RBMLayerhidden
PP< RBMConnectionconnection
TVec< string > ports
TVec< string > state_ports
int n_ports
int n_state_ports
TVec< intstate_ports_indices
int nll_index
int visible_index
int rec_err_index

Private Types

typedef Object inherited

Private Member Functions

void build_ ()
 This does the actual building.

Private Attributes

TVec< Mat * > nll_values
TVec< Mat * > rec_err_values
Mat h0_a
Mat h0_e
Mat h0_s
Mat h0
Mat v1_a
Mat v1_e
Mat v1_s
Mat v1

Detailed Description

The first sentence should be a BRIEF DESCRIPTION of what the class does.

Place the rest of the class programmer documentation here. Doxygen supports Javadoc-style comments. See http://www.doxygen.org/manual.html

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 59 of file RBMTrainer.h.


Member Typedef Documentation

Reimplemented from PLearn::Object.

Definition at line 61 of file RBMTrainer.h.


Constructor & Destructor Documentation

PLearn::RBMTrainer::RBMTrainer ( )

Default constructor.

Definition at line 58 of file RBMTrainer.cc.


Member Function Documentation

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

Reimplemented from PLearn::Object.

Definition at line 56 of file RBMTrainer.cc.

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

Reimplemented from PLearn::Object.

Definition at line 56 of file RBMTrainer.cc.

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

Reimplemented from PLearn::Object.

Definition at line 56 of file RBMTrainer.cc.

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

Reimplemented from PLearn::Object.

Definition at line 56 of file RBMTrainer.cc.

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

Reimplemented from PLearn::Object.

Definition at line 56 of file RBMTrainer.cc.

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

Reimplemented from PLearn::Object.

Definition at line 56 of file RBMTrainer.cc.

void PLearn::RBMTrainer::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 83 of file RBMTrainer.cc.

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

Here is the call graph for this function:

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

This does the actual building.

Reimplemented from PLearn::Object.

Definition at line 237 of file RBMTrainer.cc.

References PLearn::TVec< T >::append(), compute_log_likelihood, connection, data, data_filename, PLearn::find(), PLearn::get_pointer(), hidden, i, PLearn::PPath::isEmpty(), learning_rate, PLearn::TVec< T >::length(), PLearn::lowerstring(), n_hidden, n_ports, n_state_ports, n_test, n_train, n_valid, n_visible, nll_index, nll_values, PLCHECK, PLERROR, ports, rbm, rec_err_index, rec_err_values, PLearn::TVec< T >::resize(), seed, state_ports, state_ports_indices, test_input, train_input, use_fast_approximations, valid_input, visible, visible_index, and visible_type.

Referenced by build().

{
    visible_type = lowerstring(visible_type);
    PLCHECK( visible_type == "binomial" || visible_type == "gaussian" );

    // visible
    if (visible_type == "binomial")
        visible = new RBMBinomialLayer();
    else if (visible_type == "gaussian")
        visible = new RBMGaussianLayer();
    else
        PLERROR("Unknown visible_type (%s).", visible_type.c_str());

    visible->size = n_visible;
    visible->setLearningRate(learning_rate);
    visible->use_fast_approximations = use_fast_approximations;
    visible->build();

    // hidden
    hidden = new RBMBinomialLayer();
    hidden->size = n_hidden;
    hidden->setLearningRate(learning_rate);
    hidden->use_fast_approximations = use_fast_approximations;
    hidden->build();

    // connection
    connection = new RBMMatrixConnection();
    connection->down_size = n_visible;
    connection->up_size = n_hidden;
    connection->setLearningRate(learning_rate);
    connection->use_fast_approximations = use_fast_approximations;
    connection->build();

    // RBM
    rbm = new RBMModule();
    rbm->visible_layer = visible;
    rbm->hidden_layer = hidden;
    rbm->connection = connection;
    rbm->reconstruction_connection = connection;
    rbm->compute_log_likelihood = compute_log_likelihood;
    rbm->random_gen = new PRandom(seed);
    rbm->cd_learning_rate = learning_rate;
    rbm->use_fast_approximations = use_fast_approximations;
    rbm->build();

    // data
    if (!data_filename.isEmpty())
    {
        PP<AutoVMatrix> data_ = new AutoVMatrix();
        data_->filename = data_filename;
        data_->defineSizes(n_visible, 1);
        data_->build();
        data = get_pointer(data_);

        // train_input
        train_input = new SubVMatrix(data,      // source
                                     0,         // istart
                                     0,         // jstart
                                     n_train,   // length
                                     n_visible, // width
                                     true       // call_build
                                     );

        // valid_input
        valid_input = new SubVMatrix(data,
                                     n_train,
                                     0,
                                     n_valid,
                                     n_visible,
                                     true
                                     );

        // valid_input
        test_input = new SubVMatrix(data,
                                    n_train + n_valid,
                                    0,
                                    n_test,
                                    n_visible,
                                    true
                                    );
    }

    // ports
    ports = rbm->getPorts();
    n_ports = ports.length();
    for (int i=0; i<n_ports; i++)
    {
        if (ports[i].find(".state", 0) != string::npos)
        {
            state_ports.append(ports[i]);
            state_ports_indices.append(i);
        }
    }

    n_state_ports = state_ports.length();
    nll_index = rbm->getPortIndex("neg_log_likelihood");
    visible_index = rbm->getPortIndex("visible");
    rec_err_index = rbm->getPortIndex("reconstruction_error.state");

    // nll_values
    nll_values.resize(n_ports);
    for (int i=0; i<n_state_ports; i++)
        nll_values[state_ports_indices[i]] = new Mat();

    // rec_err_values
    rec_err_values.resize(n_ports);
    for (int i=0; i<n_state_ports; i++)
        rec_err_values[state_ports_indices[i]] = new Mat();
}

Here is the call graph for this function:

Here is the caller graph for this function:

void PLearn::RBMTrainer::CD1 ( const Mat examples)

Definition at line 401 of file RBMTrainer.cc.

References connection, PLearn::endl(), h0, h0_a, h0_e, h0_s, hidden, PLearn::TMat< T >::length(), n_hidden, PLearn::pout, print_debug, rbm, PLearn::TMat< T >::resize(), sample_v1_in_chain, update_with_h0_sample, v1, v1_a, v1_e, v1_s, and visible.

Referenced by declareMethods(), and run().

{
    int n_examples = examples.length();
    if (print_debug)
    {
        pout << "v0 = " << endl << examples << endl;
    }

    // Positive phase
    connection->setAsDownInputs(examples);
    hidden->getAllActivations(connection, 0, true);
    hidden->computeExpectations();
    hidden->generateSamples();

    h0_a = hidden->activations;
    h0_s.resize(n_examples, n_hidden);
    h0_s << hidden->samples.copy();

    if (update_with_h0_sample)
    {
        h0 = h0_s;
    }
    else
    {
        h0_e.resize(n_examples, n_hidden);
        h0_e << hidden->getExpectations();
        h0 = h0_e;
    }

    if (print_debug)
    {
        pout << "h0_a = " << endl << h0_a << endl;
        pout << "h0_e = " << endl << hidden->getExpectations() << endl;
        pout << "h0_s = " << endl << h0_s << endl;
    }

    // Downward pass
    connection->setAsUpInputs(h0_s);
    visible->getAllActivations(connection, 0, true);
    visible->computeExpectations();
    visible->generateSamples();

    v1_a = visible->activations;
    v1_e = visible->getExpectations();
    v1_s = visible->samples;

    // Negative phase
    if (sample_v1_in_chain)
        v1 = v1_s;
    else
        v1 = v1_e;

    if (print_debug)
    {
        pout << "v1_a = " << endl << v1_a << endl;
        pout << "v1_e = " << endl << v1_e << endl;
        pout << "v1_s = " << endl << v1_s << endl;
    }

    connection->setAsDownInputs(v1);
    hidden->getAllActivations(connection, 0, true);
    hidden->computeExpectations();

    Mat h1 = hidden->getExpectations();
    if (print_debug)
        pout << "h1 = " << endl << h1 << endl;

    rbm->CDUpdate(examples, h0, v1, h1);
}

Here is the call graph for this function:

Here is the caller graph for this function:

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

Reimplemented from PLearn::Object.

Definition at line 56 of file RBMTrainer.cc.

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

Declare methods that are intended to be remote-callable.

If you use this mechanism, you don't usually need to override the call method in derived classes. The typical form of this method is as follows:

  static void MyDerivedClass::declareMethods(RemoteMethodMap& rmm)
  {
      // Insert a backpointer to inherited methods; note that this
      // mechanism is different from that of declareOptions()
      rmm.inherited(inherited::_getRemoteMethodMap_());

      // Mind the extra pair of parenthesis around the docstrings.
      // They are necessary for proper construction of documentation.
      declareMethod(rmm, "method1", &MyDerivedClass::method1,
                    (BodyDoc("Main documentation for the method"),
                     ArgDoc ("arg1_name", "Documentation for argument1"),
                     ArgDoc ("arg2_name", "Documentation for argument2"),
                     // ... other ArgDoc here ...
                     RetDoc ("Documentation for the return value")));

      // Other calls to declareMethod() as appropriate to expose the
      // public remote-callable interface
  }

IMPORTANT REMARKS:

The types of methods that can be directly declared in this manner is restricted to methods that don't have any "result-arguments" (and are either void, or *return* their result). But in C/C++ it is customary to implement "multiple results" by passing them as "result-arguments" to the call. You can't use declareMethod on such a method: you'll first have to write a wrapper method of the correct form that you can declare with declareMethod. To *return* multiple results, you should actually return a *tuple*.

Ex: if you have a method of class PLearner with 2 "result arguments" like:

  virtual void computeOutputAndCosts(const Vec& input, const Vec& target,
                                     Vec& output, Vec& costs) const;

you can't declare it directly with declareMethod, so you'll have to write a wrapper-method that you can declare, like the following:

  tuple<Vec,Vec> PLearner::remote_computeOutputAndCosts(const Vec& input, 
                                                        const Vec& target) const
  {
    Vec output;
    Vec costs;
    computeOutputAndCosts(input,target,output,costs);
    return make_tuple(output, costs);
  }

The policy is to name such wapper methods destined for the remote method mechanism by prepending the suffix remote_, and usually to keep them private and non-virtual.

Note that from the calling-convention perspective of a C++ process remote-calling such a tuple-returning method, the results will be received as "multiple results" corresponding to the elements of the tuple, rather than as a "single result" of type tuple. If instead you *really* want your tuple to be received as a single tuple then you should return a tuple of your tuple.

Also beware, if you have several C++ methods with the same name, overloaded for different types of arguments, and you want to make them all remote callable, you should declare them with *different* corresponding string names in declareMethods. Indeed, the remote method mechanism can only distinguish methods based on their string name and number of arguments, but not on the types of the arguments.

Parameters:
rmmRemoteMethodMap to be constructed for the current class.

Reimplemented from PLearn::Object.

Definition at line 215 of file RBMTrainer.cc.

References PLearn::Object::_getRemoteMethodMap_(), CD1(), PLearn::declareMethod(), PLearn::RemoteMethodMap::inherited(), NLL(), and recError().

{
    // Make sure that inherited methods are declared
    rmm.inherited(inherited::_getRemoteMethodMap_());

    declareMethod(rmm, "NLL", &RBMTrainer::NLL,
                  (BodyDoc("Computes NLL"),
                   ArgDoc ("examples", "The examples"),
                   RetDoc ("The NLL")
                  ));

    declareMethod(rmm, "recError", &RBMTrainer::recError,
                  (BodyDoc("Computes reconstruction error"),
                   ArgDoc ("examples", "The examples"),
                   RetDoc ("The reconstruction error")
                  ));

    declareMethod(rmm, "CD1", &RBMTrainer::CD1,
                  (BodyDoc("Performs one step of CD"),
                   ArgDoc ("examples", "The examples")));
}

Here is the call graph for this function:

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

Declares the class options.

Reimplemented from PLearn::Object.

Definition at line 96 of file RBMTrainer.cc.

References batch_size, PLearn::OptionBase::buildoption, compute_log_likelihood, connection, data, data_filename, PLearn::declareOption(), PLearn::Object::declareOptions(), hidden, learning_rate, PLearn::OptionBase::learntoption, n_hidden, n_stages, n_test, n_train, n_valid, n_visible, print_debug, rbm, sample_v1_in_chain, save_name, save_path, seed, test_input, train_input, update_with_h0_sample, use_fast_approximations, valid_input, visible, and visible_type.

{
    declareOption(ol, "n_visible", &RBMTrainer::n_visible,
                  OptionBase::buildoption,
                  "n_visible");

    declareOption(ol, "n_hidden", &RBMTrainer::n_hidden,
                  OptionBase::buildoption,
                  "n_hidden");

    declareOption(ol, "visible_type", &RBMTrainer::visible_type,
                  OptionBase::buildoption,
                  "visible_type");

    declareOption(ol, "update_with_h0_sample",
                  &RBMTrainer::update_with_h0_sample,
                  OptionBase::buildoption,
                  "update_with_h0_sample");

    declareOption(ol, "sample_v1_in_chain", &RBMTrainer::sample_v1_in_chain,
                  OptionBase::buildoption,
                  "sample_v1_in_chain");

    declareOption(ol, "compute_log_likelihood",
                  &RBMTrainer::compute_log_likelihood,
                  OptionBase::buildoption,
                  "compute_log_likelihood");

    declareOption(ol, "n_stages", &RBMTrainer::n_stages,
                  OptionBase::buildoption,
                  "n_stages");

    declareOption(ol, "learning_rate", &RBMTrainer::learning_rate,
                  OptionBase::buildoption,
                  "learning_rate");

    declareOption(ol, "seed", &RBMTrainer::seed,
                  OptionBase::buildoption,
                  "seed");

    declareOption(ol, "n_train", &RBMTrainer::n_train,
                  OptionBase::buildoption,
                  "n_train");

    declareOption(ol, "n_valid", &RBMTrainer::n_valid,
                  OptionBase::buildoption,
                  "n_valid");

    declareOption(ol, "n_test", &RBMTrainer::n_test,
                  OptionBase::buildoption,
                  "n_test");

    declareOption(ol, "batch_size", &RBMTrainer::batch_size,
                  OptionBase::buildoption,
                  "batch_size");

    declareOption(ol, "data_filename", &RBMTrainer::data_filename,
                  OptionBase::buildoption,
                  "data_filename");

    declareOption(ol, "save_path", &RBMTrainer::save_path,
                  OptionBase::buildoption,
                  "save_path");

    declareOption(ol, "save_name", &RBMTrainer::save_name,
                  OptionBase::buildoption,
                  "save_name");

    declareOption(ol, "print_debug", &RBMTrainer::print_debug,
                  OptionBase::buildoption,
                  "print_debug");

    declareOption(ol, "use_fast_approximations",
                  &RBMTrainer::use_fast_approximations,
                  OptionBase::buildoption,
                  "use_fast_approximations");

    declareOption(ol, "data", &RBMTrainer::data,
                  OptionBase::learntoption,
                  "data");

    declareOption(ol, "train_input", &RBMTrainer::train_input,
                  OptionBase::learntoption,
                  "train_input");

    declareOption(ol, "valid_input", &RBMTrainer::valid_input,
                  OptionBase::learntoption,
                  "valid_input");

    declareOption(ol, "test_input", &RBMTrainer::test_input,
                  OptionBase::learntoption,
                  "test_input");

    declareOption(ol, "rbm", &RBMTrainer::rbm,
                  OptionBase::learntoption,
                  "rbm");

    declareOption(ol, "visible", &RBMTrainer::visible,
                  OptionBase::learntoption,
                  "visible");

    declareOption(ol, "hidden", &RBMTrainer::hidden,
                  OptionBase::learntoption,
                  "hidden");

    declareOption(ol, "connection", &RBMTrainer::connection,
                  OptionBase::learntoption,
                  "connection");

    /*
    declareOption(ol, "", &RBMTrainer::,
                  OptionBase::learntoption,
                  "");
    */

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

Here is the call graph for this function:

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

Reimplemented from PLearn::Object.

Definition at line 106 of file RBMTrainer.h.

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

Reimplemented from PLearn::Object.

Definition at line 56 of file RBMTrainer.cc.

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

Reimplemented from PLearn::Object.

Definition at line 56 of file RBMTrainer.cc.

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

Reimplemented from PLearn::Object.

Definition at line 56 of file RBMTrainer.cc.

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

Reimplemented from PLearn::Object.

Definition at line 56 of file RBMTrainer.cc.

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

Transforms a shallow copy into a deep copy.

Reimplemented from PLearn::Object.

Definition at line 89 of file RBMTrainer.cc.

References PLearn::Object::makeDeepCopyFromShallowCopy().

{
    inherited::makeDeepCopyFromShallowCopy(copies);

    // deepCopyField(trainvec, copies);
}

Here is the call graph for this function:

Mat PLearn::RBMTrainer::NLL ( const Mat examples)

Definition at line 347 of file RBMTrainer.cc.

References PLearn::endl(), i, PLearn::TMat< T >::length(), n_state_ports, nll_index, nll_values, PLASSERT, PLearn::pout, print_debug, rbm, PLearn::TVec< T >::size(), state_ports_indices, visible_index, and PLearn::TMat< T >::width().

Referenced by declareMethods(), and run().

{
    Mat nll;

    for (int i=0; i<n_state_ports; i++)
        nll_values[state_ports_indices[i]]->resize(0,0);

    nll_values[nll_index] = &nll;
    nll_values[visible_index] = const_cast<Mat *>(&examples);

    rbm->fprop(nll_values);

    if (print_debug)
    {
        pout << "In NLL:" << endl;
        for (int i=0; i<n_state_ports; i++)
        {
            int portnum = state_ports_indices[i];
            string portname = rbm->getPortName(portnum);
            pout << portname << ": " << nll_values[portnum]->size() << endl;
        }
    }

    PLASSERT(nll.length() == examples.length() && nll.width() == 1);
    return nll;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Mat PLearn::RBMTrainer::recError ( const Mat examples)

Definition at line 374 of file RBMTrainer.cc.

References PLearn::endl(), i, PLearn::TMat< T >::length(), n_state_ports, PLASSERT, PLearn::pout, print_debug, rbm, rec_err_index, rec_err_values, PLearn::TVec< T >::size(), state_ports_indices, visible_index, and PLearn::TMat< T >::width().

Referenced by declareMethods(), and run().

{
    Mat rec_err;
    for (int i=0; i<n_state_ports; i++)
        rec_err_values[state_ports_indices[i]]->resize(0,0);

    rec_err_values[rec_err_index] = &rec_err;
    rec_err_values[visible_index] = const_cast<Mat *>(&examples);

    rbm->fprop(rec_err_values);

    if (print_debug)
    {
        pout << "In recError:" << endl;
        for (int i=0; i<n_state_ports; i++)
        {
            int portnum = state_ports_indices[i];
            string portname = rbm->getPortName(portnum);
            pout << portname << ": " << rec_err_values[portnum]->size() << endl;
        }
    }

    PLASSERT(rec_err.length() == examples.length()
             && rec_err.width() == 1);
    return rec_err;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void PLearn::RBMTrainer::run ( ) [virtual]

Override this for runnable objects (default method issues a runtime error).

Runnable objects are objects that can be used as *THE* object of a .plearn script. The run() method specifies what they should do when executed.

Reimplemented from PLearn::Object.

Definition at line 471 of file RBMTrainer.cc.

References batch_size, CD1(), PLearn::endl(), i, PLearn::PPath::isEmpty(), PLearn::mean(), n_stages, n_test, n_train, n_valid, NLL(), PLearn::openFile(), PLearn::pout, PLearn::PStream::raw_ascii, recError(), save_name, save_path, PLearn::VMat::subMatRows(), test_input, train_input, and valid_input.

{
    Mat results(n_stages+1, 6);
    for (int stage=0; stage<n_stages; stage++)
    {
        pout << "stage: " << stage << endl;
        results(stage, 0) = mean(NLL(train_input));
        results(stage, 3) = mean(recError(train_input));

        if (n_valid > 0)
        {
            results(stage, 1) = mean(NLL(valid_input));
            results(stage, 4) = mean(recError(valid_input));
        }

        if (n_test > 0)
        {
            results(stage, 2) = mean(NLL(test_input));
            results(stage, 5) = mean(recError(test_input));
        }

        pout << "NLL:      " << results(stage).subVec(0,3) << endl;
        pout << "RecError: " << results(stage).subVec(3,3) << endl;

        for (int i=0; i<n_train/batch_size; i++)
            CD1(train_input.subMatRows(i*batch_size, batch_size));
    }
    pout << "stage: " << n_stages << endl;
    results(n_stages, 0) = mean(NLL(train_input));
    results(n_stages, 3) = mean(recError(train_input));
    if (n_valid > 0)
    {
        results(n_stages, 1) = mean(NLL(valid_input));
        results(n_stages, 4) = mean(recError(valid_input));
    }
    if (n_test > 0)
    {
        results(n_stages, 2) = mean(NLL(test_input));
        results(n_stages, 5) = mean(recError(test_input));
    }
    pout << "NLL:      " << results(n_stages).subVec(0,3) << endl;
    pout << "RecError: " << results(n_stages).subVec(3,3) << endl;
    pout << "results = " << endl << results << endl;

    if (!save_path.isEmpty())
    {
        PPath filename;
        if (save_name.isEmpty())
            filename = save_path / "results.amat";
        else
            filename = save_path / save_name;

        PStream file = openFile(filename, PStream::raw_ascii, "w");
        file << results << endl;
    }
}

Here is the call graph for this function:


Member Data Documentation

Reimplemented from PLearn::Object.

Definition at line 106 of file RBMTrainer.h.

Definition at line 80 of file RBMTrainer.h.

Referenced by declareOptions(), and run().

Definition at line 73 of file RBMTrainer.h.

Referenced by build_(), and declareOptions().

Definition at line 127 of file RBMTrainer.h.

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

Definition at line 119 of file RBMTrainer.h.

Referenced by build_(), and declareOptions().

Definition at line 81 of file RBMTrainer.h.

Referenced by build_(), and declareOptions().

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

Definition at line 162 of file RBMTrainer.h.

Referenced by CD1().

Mat PLearn::RBMTrainer::h0_a [mutable, private]

Definition at line 159 of file RBMTrainer.h.

Referenced by CD1().

Mat PLearn::RBMTrainer::h0_e [mutable, private]

Definition at line 160 of file RBMTrainer.h.

Referenced by CD1().

Mat PLearn::RBMTrainer::h0_s [mutable, private]

Definition at line 161 of file RBMTrainer.h.

Referenced by CD1().

Definition at line 126 of file RBMTrainer.h.

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

Definition at line 75 of file RBMTrainer.h.

Referenced by build_(), and declareOptions().

Definition at line 69 of file RBMTrainer.h.

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

Definition at line 131 of file RBMTrainer.h.

Referenced by build_().

Definition at line 74 of file RBMTrainer.h.

Referenced by declareOptions(), and run().

Definition at line 132 of file RBMTrainer.h.

Referenced by build_(), NLL(), and recError().

Definition at line 79 of file RBMTrainer.h.

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

Definition at line 77 of file RBMTrainer.h.

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

Definition at line 78 of file RBMTrainer.h.

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

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

Definition at line 68 of file RBMTrainer.h.

Referenced by build_(), and declareOptions().

Definition at line 134 of file RBMTrainer.h.

Referenced by build_(), and NLL().

TVec<Mat*> PLearn::RBMTrainer::nll_values [mutable, private]

Definition at line 156 of file RBMTrainer.h.

Referenced by build_(), and NLL().

TVec<string> PLearn::RBMTrainer::ports [protected]

Definition at line 129 of file RBMTrainer.h.

Referenced by build_().

Definition at line 84 of file RBMTrainer.h.

Referenced by CD1(), declareOptions(), NLL(), and recError().

Definition at line 124 of file RBMTrainer.h.

Referenced by build_(), CD1(), declareOptions(), NLL(), and recError().

Definition at line 136 of file RBMTrainer.h.

Referenced by build_(), and recError().

Definition at line 157 of file RBMTrainer.h.

Referenced by build_(), and recError().

Definition at line 72 of file RBMTrainer.h.

Referenced by CD1(), and declareOptions().

Definition at line 83 of file RBMTrainer.h.

Referenced by declareOptions(), and run().

Definition at line 82 of file RBMTrainer.h.

Referenced by declareOptions(), and run().

Definition at line 76 of file RBMTrainer.h.

Referenced by build_(), and declareOptions().

Definition at line 130 of file RBMTrainer.h.

Referenced by build_().

Definition at line 133 of file RBMTrainer.h.

Referenced by build_(), NLL(), and recError().

Definition at line 122 of file RBMTrainer.h.

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

Definition at line 120 of file RBMTrainer.h.

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

Definition at line 71 of file RBMTrainer.h.

Referenced by CD1(), and declareOptions().

Definition at line 85 of file RBMTrainer.h.

Referenced by build_(), and declareOptions().

Mat PLearn::RBMTrainer::v1 [mutable, private]

Definition at line 167 of file RBMTrainer.h.

Referenced by CD1().

Mat PLearn::RBMTrainer::v1_a [mutable, private]

Definition at line 164 of file RBMTrainer.h.

Referenced by CD1().

Mat PLearn::RBMTrainer::v1_e [mutable, private]

Definition at line 165 of file RBMTrainer.h.

Referenced by CD1().

Mat PLearn::RBMTrainer::v1_s [mutable, private]

Definition at line 166 of file RBMTrainer.h.

Referenced by CD1().

Definition at line 121 of file RBMTrainer.h.

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

Definition at line 125 of file RBMTrainer.h.

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

Definition at line 135 of file RBMTrainer.h.

Referenced by build_(), NLL(), and recError().

Definition at line 70 of file RBMTrainer.h.

Referenced by build_(), and declareOptions().


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