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

PLearn::SumOverBagsVariable Class Reference

#include <SumOverBagsVariable.h>

Inheritance diagram for PLearn::SumOverBagsVariable:

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

Collaboration graph
[legend]
List of all members.

Public Member Functions

 SumOverBagsVariable ()
 protected default constructor for persistence

 SumOverBagsVariable (VMat the_vmat, Func the_f, int maxbagsize, int nsamples, bool average, bool transpose=false)
 Sum_{bags vmat} f(inputs and targets in bag) By convention a bag is a sequence of rows of the vmat in which the last column of the target indicates whether the row is the first one (and/or) the last one, with its two least significant bits: last_column_of_target == 1 ==> first row last_column_of_target == 2 ==> last row last_column_of_target == 0 ==> intermediate row last_column_of_target == 1+2==3 ==> single-row bag (both first and last) the last column of the target is not given in the call to f, but a bag_size input is provided instead.

 PLEARN_DECLARE_OBJECT (SumOverBagsVariable)
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 makeDeepCopyFromShallowCopy (map< const void *, void * > &copies)
virtual void fprop ()
 compute output given input

virtual void bprop ()
virtual void fbprop ()
 do both fprop and bprop

virtual void fpropOneBag (bool do_bprop=false)
void printInfo (bool print_gradient)

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)


Public Attributes

VMat vmat
Func f
bool average
int max_bag_size
int n_samples
bool transpose
int curpos
 current pos in VMat

Vec output_value
Mat input_values
Vec bag_size_vec
Vec bag_target_and_bag_signal
Vec bag_target
Vec bag_signal
Vec bag_weight
Array< Vecf_inputs
Array< Vecunused_gradients
Array< Vecoutput_av
Array< Vecgradient_av
int bag_size

Static Public Attributes

const int TARGET_COLUMN_FIRST = 1
 Tags to use in the vmat given to this variable.

const int TARGET_COLUMN_LAST = 2
const int TARGET_COLUMN_SINGLE = 3
const int TARGET_COLUMN_INTERMEDIATE = 0

Protected Member Functions

void build_ ()

Private Types

typedef NaryVariable inherited

Member Typedef Documentation

typedef NaryVariable PLearn::SumOverBagsVariable::inherited [private]
 

Reimplemented from PLearn::NaryVariable.

Definition at line 54 of file SumOverBagsVariable.h.

Referenced by SumOverBagsVariable().


Constructor & Destructor Documentation

PLearn::SumOverBagsVariable::SumOverBagsVariable  ) 
 

protected default constructor for persistence

Definition at line 77 of file SumOverBagsVariable.cc.

References PLearn::transpose().

PLearn::SumOverBagsVariable::SumOverBagsVariable VMat  the_vmat,
Func  the_f,
int  maxbagsize,
int  nsamples,
bool  average,
bool  transpose = false
 

Sum_{bags vmat} f(inputs and targets in bag) By convention a bag is a sequence of rows of the vmat in which the last column of the target indicates whether the row is the first one (and/or) the last one, with its two least significant bits: last_column_of_target == 1 ==> first row last_column_of_target == 2 ==> last row last_column_of_target == 0 ==> intermediate row last_column_of_target == 1+2==3 ==> single-row bag (both first and last) the last column of the target is not given in the call to f, but a bag_size input is provided instead.

The inputs to f are: (matrix of bag inputs, the bag size, the bag target, the bag weight).

Definition at line 85 of file SumOverBagsVariable.cc.

References build(), inherited, PLearn::nonInputParentsOfPath(), and PLearn::transpose().


Member Function Documentation

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

Implements PLearn::Variable.

Definition at line 346 of file SumOverBagsVariable.cc.

References fbprop().

void PLearn::SumOverBagsVariable::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 101 of file SumOverBagsVariable.cc.

References build_().

Referenced by SumOverBagsVariable().

void PLearn::SumOverBagsVariable::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 110 of file SumOverBagsVariable.cc.

References bag_signal, bag_size_vec, bag_target, bag_target_and_bag_signal, bag_weight, PLearn::TVec< Vec >::copy(), f, f_inputs, gradient_av, input_values, max_bag_size, output_av, output_value, PLERROR, PLearn::TVec< Vec >::resize(), PLearn::TVec< T >::resize(), PLearn::TMat< T >::resize(), PLearn::TVec< Vec >::size(), PLearn::TVec< T >::subVec(), PLearn::TMat< T >::toVec(), transpose, unused_gradients, vmat, and PLearn::ws().

Referenced by build().

void PLearn::SumOverBagsVariable::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::NaryVariable.

Definition at line 152 of file SumOverBagsVariable.cc.

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

void PLearn::SumOverBagsVariable::fbprop  )  [virtual]
 

do both fprop and bprop

Reimplemented from PLearn::Variable.

Definition at line 312 of file SumOverBagsVariable.cc.

References average, PLearn::TVec< T >::clear(), curpos, f, fpropOneBag(), n_samples, and PLERROR.

Referenced by bprop().

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

compute output given input

Implements PLearn::Variable.

Definition at line 280 of file SumOverBagsVariable.cc.

References average, PLearn::TVec< T >::clear(), curpos, f, fpropOneBag(), and n_samples.

void PLearn::SumOverBagsVariable::fpropOneBag bool  do_bprop = false  )  [virtual]
 

Definition at line 220 of file SumOverBagsVariable.cc.

References bag_signal, bag_size, bag_size_vec, bag_target, bag_target_and_bag_signal, bag_weight, PLearn::TMat< T >::column(), curpos, f, f_inputs, PLearn::VMat::getExample(), gradient_av, input_values, PLearn::VMat::length(), PLearn::TVec< T >::length(), PLearn::TMat< T >::length(), max_bag_size, output_av, output_value, PLERROR, PLearn::TVec< T >::resize(), PLearn::TMat< T >::resize(), PLearn::TVec< T >::subVec(), transpose, unused_gradients, vmat, and PLearn::TMat< T >::width().

Referenced by fbprop(), and fprop().

void PLearn::SumOverBagsVariable::makeDeepCopyFromShallowCopy map< const void *, void * > &  copies  )  [virtual]
 

Reimplemented from PLearn::NaryVariable.

Definition at line 198 of file SumOverBagsVariable.cc.

References bag_signal, bag_size_vec, bag_target, bag_target_and_bag_signal, bag_weight, PLearn::deepCopyField(), f, f_inputs, gradient_av, input_values, output_av, output_value, unused_gradients, and vmat.

PLearn::SumOverBagsVariable::PLEARN_DECLARE_OBJECT SumOverBagsVariable   ) 
 

void PLearn::SumOverBagsVariable::printInfo bool  print_gradient  )  [virtual]
 

Reimplemented from PLearn::NaryVariable.

Definition at line 354 of file SumOverBagsVariable.cc.

References PLearn::endl(), f, PLearn::Variable::getName(), PLearn::Object::info(), max_bag_size, and n_samples.

void PLearn::SumOverBagsVariable::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 185 of file SumOverBagsVariable.cc.

References f.


Member Data Documentation

bool PLearn::SumOverBagsVariable::average
 

Definition at line 60 of file SumOverBagsVariable.h.

Referenced by fbprop(), and fprop().

Vec PLearn::SumOverBagsVariable::bag_signal
 

Definition at line 72 of file SumOverBagsVariable.h.

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

int PLearn::SumOverBagsVariable::bag_size
 

Definition at line 78 of file SumOverBagsVariable.h.

Referenced by fpropOneBag().

Vec PLearn::SumOverBagsVariable::bag_size_vec
 

Definition at line 69 of file SumOverBagsVariable.h.

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

Vec PLearn::SumOverBagsVariable::bag_target
 

Definition at line 71 of file SumOverBagsVariable.h.

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

Vec PLearn::SumOverBagsVariable::bag_target_and_bag_signal
 

Definition at line 70 of file SumOverBagsVariable.h.

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

Vec PLearn::SumOverBagsVariable::bag_weight
 

Definition at line 73 of file SumOverBagsVariable.h.

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

int PLearn::SumOverBagsVariable::curpos
 

current pos in VMat

Definition at line 65 of file SumOverBagsVariable.h.

Referenced by fbprop(), fprop(), and fpropOneBag().

Func PLearn::SumOverBagsVariable::f
 

Definition at line 59 of file SumOverBagsVariable.h.

Referenced by build_(), fbprop(), fprop(), fpropOneBag(), makeDeepCopyFromShallowCopy(), printInfo(), and recomputeSize().

Array<Vec> PLearn::SumOverBagsVariable::f_inputs
 

Definition at line 74 of file SumOverBagsVariable.h.

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

Array<Vec> PLearn::SumOverBagsVariable::gradient_av
 

Definition at line 77 of file SumOverBagsVariable.h.

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

Mat PLearn::SumOverBagsVariable::input_values
 

Definition at line 68 of file SumOverBagsVariable.h.

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

int PLearn::SumOverBagsVariable::max_bag_size
 

Definition at line 61 of file SumOverBagsVariable.h.

Referenced by build_(), fpropOneBag(), and printInfo().

int PLearn::SumOverBagsVariable::n_samples
 

Definition at line 62 of file SumOverBagsVariable.h.

Referenced by fbprop(), fprop(), and printInfo().

Array<Vec> PLearn::SumOverBagsVariable::output_av
 

Definition at line 76 of file SumOverBagsVariable.h.

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

Vec PLearn::SumOverBagsVariable::output_value
 

Definition at line 67 of file SumOverBagsVariable.h.

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

const int PLearn::SumOverBagsVariable::TARGET_COLUMN_FIRST = 1 [static]
 

Tags to use in the vmat given to this variable.

Definition at line 95 of file SumOverBagsVariable.h.

const int PLearn::SumOverBagsVariable::TARGET_COLUMN_INTERMEDIATE = 0 [static]
 

Definition at line 98 of file SumOverBagsVariable.h.

const int PLearn::SumOverBagsVariable::TARGET_COLUMN_LAST = 2 [static]
 

Definition at line 96 of file SumOverBagsVariable.h.

const int PLearn::SumOverBagsVariable::TARGET_COLUMN_SINGLE = 3 [static]
 

Definition at line 97 of file SumOverBagsVariable.h.

bool PLearn::SumOverBagsVariable::transpose
 

Definition at line 63 of file SumOverBagsVariable.h.

Referenced by build_(), and fpropOneBag().

Array<Vec> PLearn::SumOverBagsVariable::unused_gradients
 

Definition at line 75 of file SumOverBagsVariable.h.

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

VMat PLearn::SumOverBagsVariable::vmat
 

Definition at line 58 of file SumOverBagsVariable.h.

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


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