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

#include <GaussMixLocalProjections.h>

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

List of all members.

Public Member Functions

 GaussMixLocalProjections ()
 Default constructor.
virtual void build ()
 Simply calls inherited::build() then build_().
virtual void makeDeepCopyFromShallowCopy (CopiesMap &copies)
 Transforms a shallow copy into a deep copy.
virtual string classname () const
virtual OptionListgetOptionList () const
virtual OptionMapgetOptionMap () const
virtual RemoteMethodMapgetRemoteMethodMap () const
virtual GaussMixLocalProjectionsdeepCopy (CopiesMap &copies) const
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 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 void computeOutputAndCosts (const Vec &input, const Vec &target, Vec &output, Vec &costs) const
 Overridden to use the default PLearner implementation.

Static Public Member Functions

static string _classname_ ()
 Declares name and deepCopy methods.
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 this class' options.

Protected Attributes

PP< GaussMixgauss_mix
 The underlying learner (same as the inherited learner_ member), but specifically a GaussMix learner.
int n_components
TVec< intoutputsizes

Private Types

typedef EmbeddedLearner inherited

Private Member Functions

void build_ ()
 This does the actual building.

Detailed Description

Definition at line 52 of file GaussMixLocalProjections.h.


Member Typedef Documentation

Reimplemented from PLearn::EmbeddedLearner.

Definition at line 56 of file GaussMixLocalProjections.h.


Constructor & Destructor Documentation

PLearn::GaussMixLocalProjections::GaussMixLocalProjections ( )

Default constructor.

Definition at line 52 of file GaussMixLocalProjections.cc.

    : n_components(-1)
{
}

Member Function Documentation

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

Declares name and deepCopy methods.

Reimplemented from PLearn::EmbeddedLearner.

Definition at line 67 of file GaussMixLocalProjections.cc.

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

Reimplemented from PLearn::EmbeddedLearner.

Definition at line 67 of file GaussMixLocalProjections.cc.

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

Reimplemented from PLearn::EmbeddedLearner.

Definition at line 67 of file GaussMixLocalProjections.cc.

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

Reimplemented from PLearn::EmbeddedLearner.

Definition at line 67 of file GaussMixLocalProjections.cc.

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

Reimplemented from PLearn::EmbeddedLearner.

Definition at line 67 of file GaussMixLocalProjections.cc.

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

Reimplemented from PLearn::EmbeddedLearner.

Definition at line 67 of file GaussMixLocalProjections.cc.

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

Simply calls inherited::build() then build_().

Reimplemented from PLearn::EmbeddedLearner.

Definition at line 107 of file GaussMixLocalProjections.cc.

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

Here is the call graph for this function:

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

This does the actual building.

Reimplemented from PLearn::EmbeddedLearner.

Definition at line 116 of file GaussMixLocalProjections.cc.

References PLearn::TVec< T >::fill(), gauss_mix, PLearn::EmbeddedLearner::inputsize(), PLearn::EmbeddedLearner::learner_, n_components, outputsizes, PLERROR, and PLearn::TVec< T >::resize().

Referenced by build().

{
    // ### This method should do the real building of the object,
    // ### according to set 'options', in *any* situation. 
    // ### Typical situations include:
    // ###  - Initial building of an object from a few user-specified options
    // ###  - Building of a "reloaded" object: i.e. from the complete set of all serialised options.
    // ###  - Updating or "re-building" of an object after a few "tuning" options have been modified.
    // ### You should assume that the parent class' build_() has already been called.
    if (learner_) {
        if (learner_->classname() != "GaussMix")
            PLERROR("In GaussMixLocalProjections::build_ - A GaussMix learner is needed");
        gauss_mix = (GaussMix*) (PLearner*) learner_;
        if (gauss_mix->type != "general")
            PLERROR("In GaussMixLocalProjections::build_ - The underlying GaussMix "
                    "distribution must be of type 'general'");
        n_components = gauss_mix->L;
        outputsizes.resize(n_components);
        outputsizes.fill(gauss_mix->n_eigen >= 0 ? gauss_mix->n_eigen : inputsize());
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

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

Reimplemented from PLearn::EmbeddedLearner.

Definition at line 67 of file GaussMixLocalProjections.cc.

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

Computes the costs from already computed output.

Reimplemented from PLearn::EmbeddedLearner.

Definition at line 141 of file GaussMixLocalProjections.cc.

{
    // No cost computed.
}                                
void PLearn::GaussMixLocalProjections::computeOutput ( const Vec input,
Vec output 
) const [virtual]

Computes the output from the input.

Reimplemented from PLearn::EmbeddedLearner.

Definition at line 150 of file GaussMixLocalProjections.cc.

References PLearn::exp(), gauss_mix, PLearn::TVec< T >::length(), PLERROR, PLearn::product(), PLearn::TVec< T >::resize(), and PLearn::TVec< T >::subVec().

{
    Mat eigen_vec;
    int size_k = gauss_mix->n_eigen > 0 ? gauss_mix->n_eigen : input.length();
    output.resize((size_k + 1) * gauss_mix->L);
    int index = 0;
    // Compute densities in order to be able to get posteriors.
    real log_density = gauss_mix->log_density(input);
    Vec log_likelihood_dens;
    // log_likelihood_dens = gauss_mix->getLogLikelihoodDens();
    PLERROR("In GaussMixLocalProjections::computeOutput - The line above must "
            "be uncommented (will not work with the modified GaussMix)");
    for (int k = 0; k < gauss_mix->L; k++) {
        // Obtain the (right number of) eigenvectors.
        output[index] = 1.0;
        // eigen_vec = gauss_mix->getEigenvectors(k).subMatRows(0, size_k);
        PLERROR("In GaussMixLocalProjections::computeOutput - The line above "
                "must be uncommented (will not work with the modified "
                "GaussMix)");
        // Compute local coordinates.
        product(output.subVec(index+1, size_k), eigen_vec, input);
        // Scale by the responsibility.
        output.subVec(index, size_k + 1) *= exp(log_likelihood_dens[k] - log_density);
        index += size_k + 1;
    }
}    

Here is the call graph for this function:

virtual void PLearn::GaussMixLocalProjections::computeOutputAndCosts ( const Vec input,
const Vec target,
Vec output,
Vec costs 
) const [inline, virtual]

Overridden to use the default PLearner implementation.

Reimplemented from PLearn::EmbeddedLearner.

Definition at line 146 of file GaussMixLocalProjections.h.

                                                                                                           {
        return PLearner::computeOutputAndCosts(input, target, output, costs);
    }
void PLearn::GaussMixLocalProjections::declareOptions ( OptionList ol) [static, protected]

Declares this class' options.

Reimplemented from PLearn::EmbeddedLearner.

Definition at line 72 of file GaussMixLocalProjections.cc.

References PLearn::declareOption(), PLearn::EmbeddedLearner::declareOptions(), PLearn::OptionBase::learntoption, n_components, PLearn::OptionBase::nosave, PLearn::PLearner::nstages, outputsizes, PLearn::redeclareOption(), and PLearn::PLearner::seed_.

{
    // ### For the "flags" of each option, you should typically specify  
    // ### one of OptionBase::buildoption, OptionBase::learntoption or 
    // ### OptionBase::tuningoption. Another possible flag to be combined with
    // ### is OptionBase::nosave

    // Build options.

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

    // Learnt options.

    declareOption(ol, "n_components", &GaussMixLocalProjections::n_components, OptionBase::learntoption,
                  "Equal to learner->L, i.e. the number of components in the mixture.");

    declareOption(ol, "outputsizes", &GaussMixLocalProjections::outputsizes, OptionBase::learntoption,
                  "The size of the projection for each Gaussian, i.e. learner->n_eigen.");

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

    redeclareOption(ol, "seed", &GaussMixLocalProjections::seed_, OptionBase::nosave,
                    "No need for a seed.");

    redeclareOption(ol, "nstages", &GaussMixLocalProjections::nstages, OptionBase::nosave,
                    "One only needs to specify mixture->nstages.");

}

Here is the call graph for this function:

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

Reimplemented from PLearn::EmbeddedLearner.

Definition at line 111 of file GaussMixLocalProjections.h.

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

Reimplemented from PLearn::EmbeddedLearner.

Definition at line 67 of file GaussMixLocalProjections.cc.

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

Reimplemented from PLearn::EmbeddedLearner.

Definition at line 67 of file GaussMixLocalProjections.cc.

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

Reimplemented from PLearn::EmbeddedLearner.

Definition at line 67 of file GaussMixLocalProjections.cc.

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

Reimplemented from PLearn::EmbeddedLearner.

Definition at line 67 of file GaussMixLocalProjections.cc.

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

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

Reimplemented from PLearn::EmbeddedLearner.

Definition at line 180 of file GaussMixLocalProjections.cc.

{
    static TVec<string> noCost;
    return noCost;
}
TVec< string > PLearn::GaussMixLocalProjections::getTrainCostNames ( ) const [virtual]

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

Reimplemented from PLearn::EmbeddedLearner.

Definition at line 189 of file GaussMixLocalProjections.cc.

{
    static TVec<string> noCost;
    return noCost;
}
void PLearn::GaussMixLocalProjections::makeDeepCopyFromShallowCopy ( CopiesMap copies) [virtual]

Transforms a shallow copy into a deep copy.

Reimplemented from PLearn::EmbeddedLearner.

Definition at line 198 of file GaussMixLocalProjections.cc.

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

{
    inherited::makeDeepCopyFromShallowCopy(copies);

    // ### ex:
    // deepCopyField(trainvec, copies);

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

Here is the call graph for this function:

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

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

Reimplemented from PLearn::EmbeddedLearner.

Definition at line 212 of file GaussMixLocalProjections.cc.

References n_components, outputsizes, and PLearn::sum().

{
    return sum(outputsizes) + n_components;
}

Here is the call graph for this function:


Member Data Documentation

Reimplemented from PLearn::EmbeddedLearner.

Definition at line 111 of file GaussMixLocalProjections.h.

The underlying learner (same as the inherited learner_ member), but specifically a GaussMix learner.

Definition at line 62 of file GaussMixLocalProjections.h.

Referenced by build_(), and computeOutput().

Definition at line 68 of file GaussMixLocalProjections.h.

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

Definition at line 69 of file GaussMixLocalProjections.h.

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


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