PLearn 0.1
|
concatenation of the columns of several variables More...
#include <ConcatColumnsVariable.h>
Public Member Functions | |
ConcatColumnsVariable () | |
Default constructor. | |
ConcatColumnsVariable (const VarArray &vararray, bool call_build_=true) | |
Convenience constructor. | |
virtual string | classname () const |
virtual OptionList & | getOptionList () const |
virtual OptionMap & | getOptionMap () const |
virtual RemoteMethodMap & | getRemoteMethodMap () const |
virtual ConcatColumnsVariable * | 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 | |
Static Public Member Functions | |
static string | _classname_ () |
ConcatColumnsVariable. | |
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_ |
Private Types | |
typedef NaryVariable | inherited |
Private Member Functions | |
void | build_ () |
Object-specific post-constructor. |
concatenation of the columns of several variables
Definition at line 53 of file ConcatColumnsVariable.h.
typedef NaryVariable PLearn::ConcatColumnsVariable::inherited [private] |
Reimplemented from PLearn::NaryVariable.
Definition at line 55 of file ConcatColumnsVariable.h.
PLearn::ConcatColumnsVariable::ConcatColumnsVariable | ( | ) | [inline] |
PLearn::ConcatColumnsVariable::ConcatColumnsVariable | ( | const VarArray & | vararray, |
bool | call_build_ = true |
||
) |
Convenience constructor.
Definition at line 61 of file ConcatColumnsVariable.cc.
References build_().
: inherited(vararray.nonNull(), vararray.maxLength(), vararray.sumOfWidths(), call_build_) { if (call_build_) build_(); }
string PLearn::ConcatColumnsVariable::_classname_ | ( | ) | [static] |
Reimplemented from PLearn::NaryVariable.
Definition at line 56 of file ConcatColumnsVariable.cc.
OptionList & PLearn::ConcatColumnsVariable::_getOptionList_ | ( | ) | [static] |
Reimplemented from PLearn::NaryVariable.
Definition at line 56 of file ConcatColumnsVariable.cc.
RemoteMethodMap & PLearn::ConcatColumnsVariable::_getRemoteMethodMap_ | ( | ) | [static] |
Reimplemented from PLearn::NaryVariable.
Definition at line 56 of file ConcatColumnsVariable.cc.
Reimplemented from PLearn::NaryVariable.
Definition at line 56 of file ConcatColumnsVariable.cc.
Object * PLearn::ConcatColumnsVariable::_new_instance_for_typemap_ | ( | ) | [static] |
Reimplemented from PLearn::Object.
Definition at line 56 of file ConcatColumnsVariable.cc.
StaticInitializer ConcatColumnsVariable::_static_initializer_ & PLearn::ConcatColumnsVariable::_static_initialize_ | ( | ) | [static] |
Reimplemented from PLearn::NaryVariable.
Definition at line 56 of file ConcatColumnsVariable.cc.
void PLearn::ConcatColumnsVariable::bprop | ( | ) | [virtual] |
Implements PLearn::Variable.
Definition at line 119 of file ConcatColumnsVariable.cc.
References PLearn::Variable::gradientdata, i, j, PLearn::TMat< T >::length(), m, PLearn::Variable::matValue, PLearn::TMat< T >::mod(), PLearn::TVec< T >::size(), and PLearn::NaryVariable::varray.
{ int n_rows = matValue.length(); int m_start = 0; int mod = matValue.mod(); for (int m=0;m<varray.size();m++) { real* mp = varray[m]->gradientdata; int n_cols = varray[m]->matGradient.width(); real* p = &gradientdata[m_start]; for (int i=0;i<n_rows;i++,p+=mod) for (int j=0;j<n_cols;j++,mp++) *mp += p[j]; m_start+=n_cols; } }
void PLearn::ConcatColumnsVariable::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 73 of file ConcatColumnsVariable.cc.
References PLearn::NaryVariable::build(), and build_().
{ inherited::build(); build_(); }
void PLearn::ConcatColumnsVariable::build_ | ( | ) | [private] |
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 82 of file ConcatColumnsVariable.cc.
References i, PLearn::Variable::length(), PLearn::TVec< T >::length(), PLERROR, PLearn::TVec< T >::size(), and PLearn::NaryVariable::varray.
Referenced by build(), and ConcatColumnsVariable().
{ if (varray->length()) { int l = varray[0]->length(); for (int i = 1; i < varray.size(); i++) if (l != varray[i]->length()) PLERROR("ConcatColumnsVariable: all non-null variables must have the same length (%d != %d)", l, varray[i]->length()); } }
string PLearn::ConcatColumnsVariable::classname | ( | ) | const [virtual] |
Reimplemented from PLearn::Object.
Definition at line 56 of file ConcatColumnsVariable.cc.
static const PPath& PLearn::ConcatColumnsVariable::declaringFile | ( | ) | [inline, static] |
ConcatColumnsVariable * PLearn::ConcatColumnsVariable::deepCopy | ( | CopiesMap & | copies | ) | const [virtual] |
Reimplemented from PLearn::NaryVariable.
Definition at line 56 of file ConcatColumnsVariable.cc.
void PLearn::ConcatColumnsVariable::fprop | ( | ) | [virtual] |
compute output given input
Implements PLearn::Variable.
Definition at line 101 of file ConcatColumnsVariable.cc.
References i, j, PLearn::TMat< T >::length(), m, PLearn::Variable::matValue, PLearn::TMat< T >::mod(), PLearn::TVec< T >::size(), PLearn::Variable::valuedata, and PLearn::NaryVariable::varray.
{ int n_rows = matValue.length(); int m_start = 0; int mod = matValue.mod(); for (int m=0;m<varray.size();m++) { real* mp = varray[m]->valuedata; int n_cols = varray[m]->matValue.width(); real* p = &valuedata[m_start]; for (int i=0;i<n_rows;i++,p+=mod) for (int j=0;j<n_cols;j++,mp++) p[j] = *mp; m_start+=n_cols; } }
OptionList & PLearn::ConcatColumnsVariable::getOptionList | ( | ) | const [virtual] |
Reimplemented from PLearn::Object.
Definition at line 56 of file ConcatColumnsVariable.cc.
OptionMap & PLearn::ConcatColumnsVariable::getOptionMap | ( | ) | const [virtual] |
Reimplemented from PLearn::Object.
Definition at line 56 of file ConcatColumnsVariable.cc.
RemoteMethodMap & PLearn::ConcatColumnsVariable::getRemoteMethodMap | ( | ) | const [virtual] |
Reimplemented from PLearn::Object.
Definition at line 56 of file ConcatColumnsVariable.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 92 of file ConcatColumnsVariable.cc.
References PLearn::VarArray::maxLength(), PLearn::VarArray::sumOfWidths(), and PLearn::NaryVariable::varray.
void PLearn::ConcatColumnsVariable::symbolicBprop | ( | ) | [virtual] |
compute a piece of new Var graph that represents the symbolic derivative of this Var
Reimplemented from PLearn::Variable.
Definition at line 137 of file ConcatColumnsVariable.cc.
References PLearn::Variable::g, PLearn::Variable::length(), n, PLearn::TVec< T >::size(), PLearn::NaryVariable::varray, and PLearn::Var::width().
{ int k=0; for (int n=0; n<varray.size(); n++) { Var vn = varray[n]; vn->accg(new SubMatVariable(g, 0, k, length(), vn->width())); k += vn->width(); } }
Reimplemented from PLearn::NaryVariable.
Definition at line 65 of file ConcatColumnsVariable.h.