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

Let define f(x) = (x-min)/(max-min) for min<=x<=max, then this variable is defined by [x1,x2,...,xn] |-> [ f(x1), 1-f(x1), f(x2), 1-f(x2), ... More...

#include <ProbabilityPairsVariable.h>

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

List of all members.

Public Member Functions

 ProbabilityPairsVariable ()
 Default constructor, usually does nothing.
 ProbabilityPairsVariable (Variable *input, real min, real max)
 ProbabilityPairsVariable (Variable *input, real max)
 ProbabilityPairsVariable (Variable *input)
virtual void recomputeSize (int &l, int &w) const
 Recomputes the length l and width w that this variable should have, according to its parent variables.
virtual void fprop ()
 Nothing to do by default.
virtual void bprop ()
 Nothing to do by default.
virtual string classname () const
virtual OptionListgetOptionList () const
virtual OptionMapgetOptionMap () const
virtual RemoteMethodMapgetRemoteMethodMap () const
virtual ProbabilityPairsVariabledeepCopy (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_ ()
 ProbabilityPairsVariable.
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

real min
 ### declare public option fields (such as build options) here Start your comments with Doxygen-compatible comments such as //!
real max
 same as min but for upper bound

Static Public Attributes

static StaticInitializer _static_initializer_

Static Protected Member Functions

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

Private Types

typedef UnaryVariable inherited

Private Member Functions

void build_ ()
 This does the actual building.

Detailed Description

Let define f(x) = (x-min)/(max-min) for min<=x<=max, then this variable is defined by [x1,x2,...,xn] |-> [ f(x1), 1-f(x1), f(x2), 1-f(x2), ...

* ProbabilityPairsVariable * , f(xn), 1-f(xn) ]

This can be interpreted as pairs of probabilities

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 61 of file ProbabilityPairsVariable.h.


Member Typedef Documentation

Reimplemented from PLearn::UnaryVariable.

Definition at line 63 of file ProbabilityPairsVariable.h.


Constructor & Destructor Documentation

PLearn::ProbabilityPairsVariable::ProbabilityPairsVariable ( )

Default constructor, usually does nothing.

Definition at line 53 of file ProbabilityPairsVariable.cc.

    : min(0.), max(1.)
{}
PLearn::ProbabilityPairsVariable::ProbabilityPairsVariable ( Variable input,
real  min,
real  max 
)

Definition at line 57 of file ProbabilityPairsVariable.cc.

References build_().

    : inherited(input, input->length(), input->width()*2),
      min(min),max(max)
{
    build_();
}

Here is the call graph for this function:

PLearn::ProbabilityPairsVariable::ProbabilityPairsVariable ( Variable input,
real  max 
)

Definition at line 64 of file ProbabilityPairsVariable.cc.

References build_().

    :inherited(input, input->length(), input->width()*2),
     min(0.), max(max)
{
    build_();
}

Here is the call graph for this function:

PLearn::ProbabilityPairsVariable::ProbabilityPairsVariable ( Variable input)

Definition at line 71 of file ProbabilityPairsVariable.cc.

References build_().

    :inherited(input, input->length(), input->width()*2),
     min(0.), max(1.)
{
    build_();
}

Here is the call graph for this function:


Member Function Documentation

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

ProbabilityPairsVariable.

Reimplemented from PLearn::UnaryVariable.

Definition at line 51 of file ProbabilityPairsVariable.cc.

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 51 of file ProbabilityPairsVariable.cc.

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 51 of file ProbabilityPairsVariable.cc.

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 51 of file ProbabilityPairsVariable.cc.

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 51 of file ProbabilityPairsVariable.cc.

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 51 of file ProbabilityPairsVariable.cc.

void PLearn::ProbabilityPairsVariable::bprop ( ) [virtual]

Nothing to do by default.

Reimplemented from PLearn::UnaryVariable.

Definition at line 101 of file ProbabilityPairsVariable.cc.

References i, PLearn::UnaryVariable::input, PLearn::Variable::length(), PLearn::Variable::matGradient, max, min, n, and PLearn::Var::width().

{
    for(int n=0; n<length(); n++)
        for(int i=0; i<input->width(); i++)
            input->matGradient(n,i) += 1./(max-min)*(matGradient(n,2*i) - matGradient(n,2*i+1));
}

Here is the call graph for this function:

void PLearn::ProbabilityPairsVariable::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::UnaryVariable.

Definition at line 115 of file ProbabilityPairsVariable.cc.

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

Here is the call graph for this function:

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

This does the actual building.

Reimplemented from PLearn::UnaryVariable.

Definition at line 160 of file ProbabilityPairsVariable.cc.

Referenced by build(), and ProbabilityPairsVariable().

{
    // ### 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.
}

Here is the caller graph for this function:

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 51 of file ProbabilityPairsVariable.cc.

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

Declares the class options.

Reimplemented from PLearn::UnaryVariable.

Definition at line 135 of file ProbabilityPairsVariable.cc.

References PLearn::OptionBase::buildoption, PLearn::declareOption(), PLearn::UnaryVariable::declareOptions(), max, and min.

{
    // ### Declare all of this object's options here.
    // ### For the "flags" of each option, you should typically specify
    // ### one of OptionBase::buildoption, OptionBase::learntoption or
    // ### OptionBase::tuningoption. If you don't provide one of these three,
    // ### this option will be ignored when loading values from a script.
    // ### You can also combine flags, for example with OptionBase::nosave:
    // ### (OptionBase::buildoption | OptionBase::nosave)

    
    declareOption(ol, "min", &ProbabilityPairsVariable::min,
                  OptionBase::buildoption,
                  "The lower bound a value of the input should be. It will be used to calculate the corresponding probability of each input.");

    declareOption(ol, "max", &ProbabilityPairsVariable::max,
                  OptionBase::buildoption,
                  "analog to min");

    

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

Here is the call graph for this function:

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 107 of file ProbabilityPairsVariable.h.

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 51 of file ProbabilityPairsVariable.cc.

void PLearn::ProbabilityPairsVariable::fprop ( ) [virtual]

Nothing to do by default.

Reimplemented from PLearn::UnaryVariable.

Definition at line 88 of file ProbabilityPairsVariable.cc.

References i, PLearn::UnaryVariable::input, PLearn::Var::length(), PLearn::Variable::matValue, max, min, n, and PLearn::Var::width().

{
    real prob;
    for(int n=0; n<input->length(); n++)
        for(int i=0; i<input->width(); i++)
        {
            prob = (input->matValue(n,i)-min)/(max-min);
            matValue(n,2*i) = prob;
            matValue(n,2*i+1) = 1.-prob;
        }
}

Here is the call graph for this function:

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 51 of file ProbabilityPairsVariable.cc.

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 51 of file ProbabilityPairsVariable.cc.

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 51 of file ProbabilityPairsVariable.cc.

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

Transforms a shallow copy into a deep copy.

Reimplemented from PLearn::UnaryVariable.

Definition at line 121 of file ProbabilityPairsVariable.cc.

References PLearn::UnaryVariable::makeDeepCopyFromShallowCopy().

{
    inherited::makeDeepCopyFromShallowCopy(copies);

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

    // ### If you want to deepCopy a Var field:
    // varDeepCopyField(somevariable, copies);
}

Here is the call graph for this function:

void PLearn::ProbabilityPairsVariable::recomputeSize ( int l,
int w 
) const [virtual]

Recomputes the length l and width w that this variable should have, according to its parent variables.

This is used for ex. by sizeprop() The default version stupidly returns the current dimensions, so make sure to overload it in subclasses if this is not appropriate.

Reimplemented from PLearn::Variable.

Definition at line 78 of file ProbabilityPairsVariable.cc.

References PLearn::UnaryVariable::input, PLearn::Var::length(), and PLearn::Var::width().

{   
        if (input) {
            l = input->length(); // the computed length of this Var
            w = input->width()*2; // the computed width
        } else
            l = w = 0;
}

Here is the call graph for this function:


Member Data Documentation

Reimplemented from PLearn::UnaryVariable.

Definition at line 107 of file ProbabilityPairsVariable.h.

same as min but for upper bound

Definition at line 77 of file ProbabilityPairsVariable.h.

Referenced by bprop(), declareOptions(), and fprop().

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

the lower bound a value of the input should be it will be used to calculate the corresponding probability of each input

Definition at line 74 of file ProbabilityPairsVariable.h.

Referenced by bprop(), declareOptions(), and fprop().


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