PLearn 0.1
|
concatenation of the rows of several variables More...
#include <ConcatRowsVariable.h>
Public Member Functions | |
ConcatRowsVariable () | |
Default constructor for persistence. | |
ConcatRowsVariable (const VarArray &vararray) | |
all the variables must have the same number of columns | |
virtual string | classname () const |
virtual OptionList & | getOptionList () const |
virtual OptionMap & | getOptionMap () const |
virtual RemoteMethodMap & | getRemoteMethodMap () const |
virtual ConcatRowsVariable * | deepCopy (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 () |
Static Public Member Functions | |
static string | _classname_ () |
ConcatRowsVariable. | |
static OptionList & | _getOptionList_ () |
static RemoteMethodMap & | _getRemoteMethodMap_ () |
static Object * | _new_instance_for_typemap_ () |
static bool | _isa_ (const Object *o) |
static void | _static_initialize_ () |
static const PPath & | declaringFile () |
Static Public Attributes | |
static StaticInitializer | _static_initializer_ |
Protected Member Functions | |
void | build_ () |
Object-specific post-constructor. | |
Private Types | |
typedef NaryVariable | inherited |
concatenation of the rows of several variables
Definition at line 53 of file ConcatRowsVariable.h.
typedef NaryVariable PLearn::ConcatRowsVariable::inherited [private] |
Reimplemented from PLearn::NaryVariable.
Definition at line 55 of file ConcatRowsVariable.h.
PLearn::ConcatRowsVariable::ConcatRowsVariable | ( | ) | [inline] |
PLearn::ConcatRowsVariable::ConcatRowsVariable | ( | const VarArray & | vararray | ) |
all the variables must have the same number of columns
Definition at line 57 of file ConcatRowsVariable.cc.
References build_().
string PLearn::ConcatRowsVariable::_classname_ | ( | ) | [static] |
Reimplemented from PLearn::NaryVariable.
Definition at line 55 of file ConcatRowsVariable.cc.
OptionList & PLearn::ConcatRowsVariable::_getOptionList_ | ( | ) | [static] |
Reimplemented from PLearn::NaryVariable.
Definition at line 55 of file ConcatRowsVariable.cc.
RemoteMethodMap & PLearn::ConcatRowsVariable::_getRemoteMethodMap_ | ( | ) | [static] |
Reimplemented from PLearn::NaryVariable.
Definition at line 55 of file ConcatRowsVariable.cc.
Reimplemented from PLearn::NaryVariable.
Definition at line 55 of file ConcatRowsVariable.cc.
Object * PLearn::ConcatRowsVariable::_new_instance_for_typemap_ | ( | ) | [static] |
Reimplemented from PLearn::Object.
Definition at line 55 of file ConcatRowsVariable.cc.
StaticInitializer ConcatRowsVariable::_static_initializer_ & PLearn::ConcatRowsVariable::_static_initialize_ | ( | ) | [static] |
Reimplemented from PLearn::NaryVariable.
Definition at line 55 of file ConcatRowsVariable.cc.
void PLearn::ConcatRowsVariable::bprop | ( | ) | [virtual] |
Implements PLearn::Variable.
Definition at line 104 of file ConcatRowsVariable.cc.
References PLearn::Variable::gradientdata, i, n, PLearn::TVec< T >::size(), and PLearn::NaryVariable::varray.
{ int k=0; for (int n=0; n<varray.size(); n++) { Var vn = varray[n]; for (int i=0; i<vn->nelems(); i++, k++) vn->gradientdata[i] += gradientdata[k]; } }
void PLearn::ConcatRowsVariable::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::NaryVariable.
Definition at line 64 of file ConcatRowsVariable.cc.
References PLearn::NaryVariable::build(), and build_().
{ inherited::build(); build_(); }
void PLearn::ConcatRowsVariable::build_ | ( | ) | [protected] |
Object-specific post-constructor.
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 its parent's build_()
has already been called.
Reimplemented from PLearn::NaryVariable.
Definition at line 71 of file ConcatRowsVariable.cc.
References i, PLearn::TVec< T >::length(), PLERROR, PLearn::TVec< T >::size(), PLearn::NaryVariable::varray, w, and PLearn::Variable::width().
Referenced by build(), and ConcatRowsVariable().
{ // all the variables must have the same width if (varray->length()) { int w = varray[0]->width(); for (int i = 1; i < varray.size(); i++) if (w != varray[i]->width()) PLERROR("ConcatRowsVariable: all non-null variables must have the same width (%d != %d)", w, varray[i]->width()); } }
string PLearn::ConcatRowsVariable::classname | ( | ) | const [virtual] |
Reimplemented from PLearn::Object.
Definition at line 55 of file ConcatRowsVariable.cc.
static const PPath& PLearn::ConcatRowsVariable::declaringFile | ( | ) | [inline, static] |
Reimplemented from PLearn::NaryVariable.
Definition at line 63 of file ConcatRowsVariable.h.
: void build_();
ConcatRowsVariable * PLearn::ConcatRowsVariable::deepCopy | ( | CopiesMap & | copies | ) | const [virtual] |
Reimplemented from PLearn::NaryVariable.
Definition at line 55 of file ConcatRowsVariable.cc.
void PLearn::ConcatRowsVariable::fprop | ( | ) | [virtual] |
compute output given input
Implements PLearn::Variable.
Definition at line 93 of file ConcatRowsVariable.cc.
References i, n, PLearn::TVec< T >::size(), PLearn::Variable::valuedata, and PLearn::NaryVariable::varray.
{ int k=0; for (int n=0; n<varray.size(); n++) { Var vn = varray[n]; for (int i=0; i<vn->nelems(); i++, k++) valuedata[k] = vn->valuedata[i]; } }
OptionList & PLearn::ConcatRowsVariable::getOptionList | ( | ) | const [virtual] |
Reimplemented from PLearn::Object.
Definition at line 55 of file ConcatRowsVariable.cc.
OptionMap & PLearn::ConcatRowsVariable::getOptionMap | ( | ) | const [virtual] |
Reimplemented from PLearn::Object.
Definition at line 55 of file ConcatRowsVariable.cc.
RemoteMethodMap & PLearn::ConcatRowsVariable::getRemoteMethodMap | ( | ) | const [virtual] |
Reimplemented from PLearn::Object.
Definition at line 55 of file ConcatRowsVariable.cc.
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 83 of file ConcatRowsVariable.cc.
References PLearn::VarArray::maxWidth(), PLearn::VarArray::sumOfLengths(), and PLearn::NaryVariable::varray.
{ if (varray) { l = varray.sumOfLengths(); w = varray.maxWidth(); // Note: actually, all vars have same width. } else l = w = 0; }
void PLearn::ConcatRowsVariable::rfprop | ( | ) | [virtual] |
Reimplemented from PLearn::Variable.
Definition at line 126 of file ConcatRowsVariable.cc.
References i, PLearn::TVec< T >::length(), n, PLearn::NaryVariable::resizeRValue(), PLearn::Variable::rValue, PLearn::Variable::rvaluedata, PLearn::TVec< T >::size(), and PLearn::NaryVariable::varray.
{ if (rValue.length()==0) resizeRValue(); int k=0; for (int n=0; n<varray.size(); n++) { Var vn = varray[n]; for (int i=0; i<vn->nelems(); i++, k++) rvaluedata[k] = vn->rvaluedata[i]; } }
void PLearn::ConcatRowsVariable::symbolicBprop | ( | ) | [virtual] |
compute a piece of new Var graph that represents the symbolic derivative of this Var
Reimplemented from PLearn::Variable.
Definition at line 115 of file ConcatRowsVariable.cc.
References PLearn::Variable::g, PLearn::Var::length(), n, PLearn::TVec< T >::size(), PLearn::NaryVariable::varray, and PLearn::Variable::width().
{ int k=0; for (int n=0; n<varray.size(); n++) { Var vn = varray[n]; vn->accg(new SubMatVariable(g, k, 0, vn->length(), width())); k += vn->length(); } }
Reimplemented from PLearn::NaryVariable.
Definition at line 63 of file ConcatRowsVariable.h.