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

PLearn::OneHotVMatrix Class Reference

#include <OneHotVMatrix.h>

Inheritance diagram for PLearn::OneHotVMatrix:

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

Collaboration graph
[legend]
List of all members.

Public Member Functions

 OneHotVMatrix ()
 default constructor (for automatic deserialization)

 OneHotVMatrix (VMat the_underlying_distr, int the_nclasses, real the_cold_value=0.0, real the_host_value=1.0)
 (see special case when nclasses==1 desribed above) Warning: VMFields are NOT YET handled by this constructor

 PLEARN_DECLARE_OBJECT (OneHotVMatrix)
virtual void build ()
 Should call simply inherited::build(), then this class's build_().

virtual void reset_dimensions ()
 in case the dimensions of an underlying vmat has changed, recompute it

virtual real dot (int i1, int i2, int inputsize) const
virtual real dot (int i, const Vec &v) const
 returns the result of the dot product between row i and the given vec (only v.length() first elements of row i are considered).


Protected Member Functions

virtual void getNewRow (int i, const Vec &samplevec) const
 This is the only method requiring implementation in subclasses.


Static Protected 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 Attributes

VMat underlying_distr
int nclasses
real cold_value
real hot_value

Private Types

typedef RowBufferedVMatrix inherited

Private Member Functions

void build_ ()
 This does the actual building.


Detailed Description

This VMat is built from another VMat Sampling from this VMat will return the corresponding sample from the underlying VMat with last element ('target_classnum') replaced by a vector of target_values of size nclasses in which only target_values[target_classnum] is set to hot_value , and all the others are set to cold_value In the special case where the VMat is built with nclasses==1, then it is assumed that we have a 2 class classification problem but we are using a single valued target. For this special case only the_cold_value is used as target for classnum 0 and the_hot_value is used for classnum 1

Definition at line 64 of file OneHotVMatrix.h.


Member Typedef Documentation

typedef RowBufferedVMatrix PLearn::OneHotVMatrix::inherited [private]
 

Reimplemented from PLearn::RowBufferedVMatrix.

Definition at line 66 of file OneHotVMatrix.h.

Referenced by OneHotVMatrix().


Constructor & Destructor Documentation

PLearn::OneHotVMatrix::OneHotVMatrix  ) 
 

default constructor (for automatic deserialization)

Definition at line 51 of file OneHotVMatrix.cc.

PLearn::OneHotVMatrix::OneHotVMatrix VMat  the_underlying_distr,
int  the_nclasses,
real  the_cold_value = 0.0,
real  the_host_value = 1.0
 

(see special case when nclasses==1 desribed above) Warning: VMFields are NOT YET handled by this constructor

Definition at line 56 of file OneHotVMatrix.cc.

References inherited.


Member Function Documentation

void PLearn::OneHotVMatrix::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::VMatrix.

Definition at line 65 of file OneHotVMatrix.cc.

References build_().

void PLearn::OneHotVMatrix::build_  )  [private]
 

This does the actual building.

Reimplemented from PLearn::VMatrix.

Definition at line 72 of file OneHotVMatrix.cc.

Referenced by build().

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

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

Definition at line 77 of file OneHotVMatrix.cc.

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

real PLearn::OneHotVMatrix::dot int  i,
const Vec v
const [virtual]
 

returns the result of the dot product between row i and the given vec (only v.length() first elements of row i are considered).

Reimplemented from PLearn::RowBufferedVMatrix.

Definition at line 106 of file OneHotVMatrix.cc.

References underlying_distr.

real PLearn::OneHotVMatrix::dot int  i1,
int  i2,
int  inputsize
const [virtual]
 

returns the dot product between row i1 and row i2 (considering only the inputsize first elements). The default version in VMatrix is somewhat inefficient, as it repeatedly calls get(i,j) The default version in RowBufferedVMatrix is a little better as it buffers the 2 Vecs between calls in case one of them is needed again. But the real strength of this method is for specialised and efficient versions in subbclasses. This method is typically used by SmartKernels so that they can compute kernel values between input samples efficiently.

Reimplemented from PLearn::RowBufferedVMatrix.

Definition at line 101 of file OneHotVMatrix.cc.

References underlying_distr.

void PLearn::OneHotVMatrix::getNewRow int  i,
const Vec samplevec
const [protected, virtual]
 

This is the only method requiring implementation in subclasses.

Implements PLearn::RowBufferedVMatrix.

Definition at line 86 of file OneHotVMatrix.cc.

References cold_value, PLearn::fill_one_hot(), PLearn::VMat::getSubRow(), hot_value, PLearn::TVec< T >::length(), PLearn::VMatrix::length(), nclasses, PLERROR, PLearn::TVec< T >::subVec(), underlying_distr, PLearn::Vec, PLearn::VMat::width(), and PLearn::VMatrix::width().

PLearn::OneHotVMatrix::PLEARN_DECLARE_OBJECT OneHotVMatrix   ) 
 

virtual void PLearn::OneHotVMatrix::reset_dimensions  )  [inline, virtual]
 

in case the dimensions of an underlying vmat has changed, recompute it

Reimplemented from PLearn::VMatrix.

Definition at line 95 of file OneHotVMatrix.h.

References PLearn::VMat::length(), underlying_distr, and PLearn::VMat::width().


Member Data Documentation

real PLearn::OneHotVMatrix::cold_value [protected]
 

Definition at line 71 of file OneHotVMatrix.h.

Referenced by getNewRow().

real PLearn::OneHotVMatrix::hot_value [protected]
 

Definition at line 72 of file OneHotVMatrix.h.

Referenced by getNewRow().

int PLearn::OneHotVMatrix::nclasses [protected]
 

Definition at line 70 of file OneHotVMatrix.h.

Referenced by getNewRow().

VMat PLearn::OneHotVMatrix::underlying_distr [protected]
 

Definition at line 69 of file OneHotVMatrix.h.

Referenced by dot(), getNewRow(), and reset_dimensions().


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