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

#include <ReIndexedTargetVariable.h>

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

List of all members.

Public Member Functions

 ReIndexedTargetVariable ()
 Default constructor for persistence.
 ReIndexedTargetVariable (Variable *input1, Variable *input2, VMat the_source, TVec< int > the_target_cols)
 ReIndexedTargetVariable (Variable *input1, Variable *input2, PP< Dictionary > the_dict, TVec< int > the_target_cols)
virtual string classname () const
virtual OptionListgetOptionList () const
virtual OptionMapgetOptionMap () const
virtual RemoteMethodMapgetRemoteMethodMap () const
virtual ReIndexedTargetVariabledeepCopy (CopiesMap &copies) const
virtual void build ()
 Post-constructor.
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 ()
 compute output given input
virtual void bprop ()
virtual void symbolicBprop ()
 compute a piece of new Var graph that represents the symbolic derivative of this Var
virtual void rfprop ()
virtual void makeDeepCopyFromShallowCopy (CopiesMap &copies)
 Does the necessary operations to transform a shallow copy (this) into a deep copy by deep-copying all the members that need to be.

Static Public Member Functions

static string _classname_ ()
 ReIndexedTargetVariable.
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 void declareOptions (OptionList &ol)
 Declare options (data fields) for the class.

Public Attributes

VMat source
 VMatrix that gives the possible values for the target columns.
TVec< inttarget_cols
 Target columns.
PP< Dictionarydict
 Alternatively, the user can give a Dictionary to reindexe If source is not null, then this field is ignored.

Static Public Attributes

static StaticInitializer _static_initializer_

Protected Member Functions

void build_ ()
 This does the actual building.

Protected Attributes

Vec row
Vec values
TVec< string > options

Private Types

typedef BinaryVariable inherited

Detailed Description

Definition at line 63 of file ReIndexedTargetVariable.h.


Member Typedef Documentation

Reimplemented from PLearn::BinaryVariable.

Definition at line 65 of file ReIndexedTargetVariable.h.


Constructor & Destructor Documentation

PLearn::ReIndexedTargetVariable::ReIndexedTargetVariable ( )

Default constructor for persistence.

Definition at line 65 of file ReIndexedTargetVariable.cc.

{}
PLearn::ReIndexedTargetVariable::ReIndexedTargetVariable ( Variable input1,
Variable input2,
VMat  the_source,
TVec< int the_target_cols 
)

Definition at line 68 of file ReIndexedTargetVariable.cc.

References build_().

    : inherited(input1, input2, input1->length(), input1->width()), source(the_source), target_cols(the_target_cols)
{
    build_();
}

Here is the call graph for this function:

PLearn::ReIndexedTargetVariable::ReIndexedTargetVariable ( Variable input1,
Variable input2,
PP< Dictionary the_dict,
TVec< int the_target_cols 
)

Definition at line 74 of file ReIndexedTargetVariable.cc.

References build_().

    : inherited(input1, input2, input1->length(), input1->width()), target_cols(the_target_cols), dict(the_dict)
{
    build_();
}

Here is the call graph for this function:


Member Function Documentation

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

ReIndexedTargetVariable.

Reimplemented from PLearn::BinaryVariable.

Definition at line 62 of file ReIndexedTargetVariable.cc.

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

Reimplemented from PLearn::BinaryVariable.

Definition at line 62 of file ReIndexedTargetVariable.cc.

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

Reimplemented from PLearn::BinaryVariable.

Definition at line 62 of file ReIndexedTargetVariable.cc.

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

Reimplemented from PLearn::BinaryVariable.

Definition at line 62 of file ReIndexedTargetVariable.cc.

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

Reimplemented from PLearn::Object.

Definition at line 62 of file ReIndexedTargetVariable.cc.

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

Reimplemented from PLearn::BinaryVariable.

Definition at line 62 of file ReIndexedTargetVariable.cc.

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

Implements PLearn::Variable.

Definition at line 150 of file ReIndexedTargetVariable.cc.

{}
void PLearn::ReIndexedTargetVariable::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::BinaryVariable.

Definition at line 81 of file ReIndexedTargetVariable.cc.

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

Here is the call graph for this function:

void PLearn::ReIndexedTargetVariable::build_ ( ) [protected]

This does the actual building.

Reimplemented from PLearn::BinaryVariable.

Definition at line 88 of file ReIndexedTargetVariable.cc.

References dict, PLearn::BinaryVariable::input1, PLearn::BinaryVariable::input2, PLearn::TVec< T >::length(), MISSING_VALUE, options, PLERROR, PLearn::TVec< T >::resize(), row, source, PLearn::TVec< T >::subVec(), target_cols, and PLearn::VMat::width().

Referenced by build(), and ReIndexedTargetVariable().

{
    if (input1 && input2 && source) {
        if(!input1->isVec()) 
            PLERROR("In ReIndexedTargetVariable: input1 must be a vector var");
        if(!input2->isVec())
            PLERROR("In ReIndexedTargetVariable: input2 must be a vector var");

        if(input1->size() != target_cols.length())
            PLERROR("In ReIndexedTargetVariable: input1 should be of size target_cols.length()");        
        if(input2->size() != source->inputsize())
            PLERROR("In ReIndexedTargetVariable: input2 should be of size source->inputsize()");

        row.resize(source->width());
        row.subVec(source->inputsize(),source->width()-source->inputsize()).fill(MISSING_VALUE);        
    }
    else if (input1 && dict)
    {
        if(!input1->isVec()) 
            PLERROR("In ReIndexedTargetVariable: input1 must be a vector var");

        if(input1->size() != target_cols.length())
            PLERROR("In ReIndexedTargetVariable: input1 should be of size target_cols.length()");        
    }
    options.resize(0);
}

Here is the call graph for this function:

Here is the caller graph for this function:

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

Reimplemented from PLearn::Object.

Definition at line 62 of file ReIndexedTargetVariable.cc.

void PLearn::ReIndexedTargetVariable::declareOptions ( OptionList ol) [static]

Declare options (data fields) for the class.

Redefine this in subclasses: call declareOption(...) for each option, and then call inherited::declareOptions(options). Please call the inherited method AT THE END to get the options listed in a consistent order (from most recently defined to least recently defined).

  static void MyDerivedClass::declareOptions(OptionList& ol)
  {
      declareOption(ol, "inputsize", &MyObject::inputsize_,
                    OptionBase::buildoption,
                    "The size of the input; it must be provided");
      declareOption(ol, "weights", &MyObject::weights,
                    OptionBase::learntoption,
                    "The learned model weights");
      inherited::declareOptions(ol);
  }
Parameters:
olList of options that is progressively being constructed for the current class.

Reimplemented from PLearn::BinaryVariable.

Definition at line 116 of file ReIndexedTargetVariable.cc.

References PLearn::OptionBase::buildoption, PLearn::declareOption(), PLearn::BinaryVariable::declareOptions(), dict, source, and target_cols.

Here is the call graph for this function:

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

Reimplemented from PLearn::BinaryVariable.

Definition at line 87 of file ReIndexedTargetVariable.h.

:
    void build_();
ReIndexedTargetVariable * PLearn::ReIndexedTargetVariable::deepCopy ( CopiesMap copies) const [virtual]

Reimplemented from PLearn::BinaryVariable.

Definition at line 62 of file ReIndexedTargetVariable.cc.

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

compute output given input

Implements PLearn::Variable.

Definition at line 128 of file ReIndexedTargetVariable.cc.

References dict, PLearn::TVec< T >::find(), for(), PLearn::BinaryVariable::input1, PLearn::BinaryVariable::input2, j, options, PLERROR, row, source, PLearn::TVec< T >::subVec(), target_cols, PLearn::Variable::valuedata, and values.

{
    if(source) row.subVec(0,source->inputsize()) << input2->value;
    
    for (int j=0; j<input1->size(); j++)
    {          
        if(source)
        {
            source->getValues(row,target_cols[j],values);
            valuedata[j] = values.find((int)input1->valuedata[j]);
        }
        else
        {
            dict->getValues(options,values);
            valuedata[j] = values.find((int)input1->valuedata[j]);
        }
        
        if(valuedata[j] < 0) PLERROR("In ReIndexedTargetVariable::fprop(): target %d is not among possible values",input1->valuedata[j]);
    }
}

Here is the call graph for this function:

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

Reimplemented from PLearn::Object.

Definition at line 62 of file ReIndexedTargetVariable.cc.

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

Reimplemented from PLearn::Object.

Definition at line 62 of file ReIndexedTargetVariable.cc.

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

Reimplemented from PLearn::Object.

Definition at line 62 of file ReIndexedTargetVariable.cc.

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

Does the necessary operations to transform a shallow copy (this) into a deep copy by deep-copying all the members that need to be.

This needs to be overridden by every class that adds "complex" data members to the class, such as Vec, Mat, PP<Something>, etc. Typical implementation:

  void CLASS_OF_THIS::makeDeepCopyFromShallowCopy(CopiesMap& copies)
  {
      inherited::makeDeepCopyFromShallowCopy(copies);
      deepCopyField(complex_data_member1, copies);
      deepCopyField(complex_data_member2, copies);
      ...
  }
Parameters:
copiesA map used by the deep-copy mechanism to keep track of already-copied objects.

Reimplemented from PLearn::BinaryVariable.

Definition at line 173 of file ReIndexedTargetVariable.cc.

References PLearn::deepCopyField(), dict, PLearn::BinaryVariable::makeDeepCopyFromShallowCopy(), options, row, source, target_cols, and values.

Here is the call graph for this function:

void PLearn::ReIndexedTargetVariable::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 124 of file ReIndexedTargetVariable.cc.

References PLearn::BinaryVariable::input1, PLearn::Var::length(), and PLearn::Var::width().

{ l=input1->length(); w=input1->width(); }

Here is the call graph for this function:

void PLearn::ReIndexedTargetVariable::rfprop ( ) [virtual]

Reimplemented from PLearn::Variable.

Definition at line 160 of file ReIndexedTargetVariable.cc.

References PLERROR.

{
    PLERROR("In ReIndexedTargetVariable::rfprop(): not implemented.");
}
void PLearn::ReIndexedTargetVariable::symbolicBprop ( ) [virtual]

compute a piece of new Var graph that represents the symbolic derivative of this Var

Reimplemented from PLearn::Variable.

Definition at line 154 of file ReIndexedTargetVariable.cc.

References PLERROR.

{
    PLERROR("In ReIndexedTargetVariable::symbolicBprop(): not implemented");
}

Member Data Documentation

Reimplemented from PLearn::BinaryVariable.

Definition at line 87 of file ReIndexedTargetVariable.h.

Alternatively, the user can give a Dictionary to reindexe If source is not null, then this field is ignored.

Definition at line 79 of file ReIndexedTargetVariable.h.

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

Definition at line 70 of file ReIndexedTargetVariable.h.

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

Definition at line 68 of file ReIndexedTargetVariable.h.

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

VMatrix that gives the possible values for the target columns.

Definition at line 74 of file ReIndexedTargetVariable.h.

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

Target columns.

Definition at line 76 of file ReIndexedTargetVariable.h.

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

Definition at line 69 of file ReIndexedTargetVariable.h.

Referenced by fprop(), and makeDeepCopyFromShallowCopy().


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