Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members

PLearn::OneHotVariable Class Reference

Represents a vector of a given lenth, that has value 1 at the index given by another variable and 0 everywhere else. More...

#include <OneHotVariable.h>

Inheritance diagram for PLearn::OneHotVariable:

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

Collaboration graph
[legend]
List of all members.

Public Member Functions

 OneHotVariable ()
 Default constructor for persistence.

 OneHotVariable (int thelength, Variable *index, real the_coldvalue, real the_hotvalue)
 PLEARN_DECLARE_OBJECT (OneHotVariable)
virtual void build ()
 Should call simply inherited::build(), then this class's build_().

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 ()

Static Public Member Functions

void declareOptions (OptionList &ol)
 redefine this in subclasses: call declareOption(...) for each option, and then call inherited::declareOptions(options) ( see the declareOption function further down)


Protected Member Functions

void build_ ()

Protected Attributes

real hotvalue
real coldvalue
int length_

Private Types

typedef UnaryVariable inherited

Detailed Description

Represents a vector of a given lenth, that has value 1 at the index given by another variable and 0 everywhere else.

Definition at line 55 of file OneHotVariable.h.


Member Typedef Documentation

typedef UnaryVariable PLearn::OneHotVariable::inherited [private]
 

Reimplemented from PLearn::UnaryVariable.

Definition at line 57 of file OneHotVariable.h.

Referenced by OneHotVariable().


Constructor & Destructor Documentation

PLearn::OneHotVariable::OneHotVariable  )  [inline]
 

Default constructor for persistence.

Definition at line 66 of file OneHotVariable.h.

References coldvalue, and hotvalue.

PLearn::OneHotVariable::OneHotVariable int  thelength,
Variable index,
real  the_coldvalue,
real  the_hotvalue
 

Definition at line 56 of file OneHotVariable.cc.

References build_(), and inherited.


Member Function Documentation

void PLearn::OneHotVariable::bprop  )  [virtual]
 

Implements PLearn::Variable.

Definition at line 104 of file OneHotVariable.cc.

void PLearn::OneHotVariable::build  )  [virtual]
 

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::Variable.

Definition at line 63 of file OneHotVariable.cc.

References build_().

void PLearn::OneHotVariable::build_  )  [protected]
 

This method should be redefined in subclasses and do the actual building of the object according to previously set option fields. Constructors can just set option fields, and then call build_. This method is NOT virtual, and will typically be called only from three places: a constructor, the public virtual build() method, and possibly the public virtual read method (which calls its parent's read). build_() can assume that it's parent's build_ has already been called.

Reimplemented from PLearn::Variable.

Definition at line 70 of file OneHotVariable.cc.

References PLERROR.

Referenced by build(), and OneHotVariable().

void PLearn::OneHotVariable::declareOptions OptionList ol  )  [static]
 

redefine this in subclasses: call declareOption(...) for each option, and then call inherited::declareOptions(options) ( see the declareOption function further down)

ex: static void declareOptions(OptionList& ol) { declareOption(ol, "inputsize", &MyObject::inputsize_, OptionBase::buildoption, "the size of the input\n it must be provided"); declareOption(ol, "weights", &MyObject::weights, OptionBase::learntoption, "the learnt model weights"); inherited::declareOptions(ol); }

Reimplemented from PLearn::UnaryVariable.

Definition at line 78 of file OneHotVariable.cc.

References PLearn::declareOption(), and PLearn::OptionList.

void PLearn::OneHotVariable::fprop  )  [virtual]
 

compute output given input

Implements PLearn::Variable.

Definition at line 90 of file OneHotVariable.cc.

References coldvalue, hotvalue, and PLearn::Variable::nelems().

PLearn::OneHotVariable::PLEARN_DECLARE_OBJECT OneHotVariable   ) 
 

void PLearn::OneHotVariable::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 86 of file OneHotVariable.cc.

References length_.

void PLearn::OneHotVariable::rfprop  )  [virtual]
 

Reimplemented from PLearn::Variable.

Definition at line 110 of file OneHotVariable.cc.

References PLearn::TVec< T >::length(), and PLearn::UnaryVariable::resizeRValue().

void PLearn::OneHotVariable::symbolicBprop  )  [virtual]
 

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

Reimplemented from PLearn::Variable.

Definition at line 107 of file OneHotVariable.cc.


Member Data Documentation

real PLearn::OneHotVariable::coldvalue [protected]
 

Definition at line 61 of file OneHotVariable.h.

Referenced by fprop(), and OneHotVariable().

real PLearn::OneHotVariable::hotvalue [protected]
 

Definition at line 60 of file OneHotVariable.h.

Referenced by fprop(), and OneHotVariable().

int PLearn::OneHotVariable::length_ [protected]
 

Definition at line 62 of file OneHotVariable.h.

Referenced by recomputeSize().


The documentation for this class was generated from the following files:
Generated on Tue Aug 17 16:25:23 2004 for PLearn by doxygen 1.3.7