PLearn 0.1
|
A convolve var; equals convolve(input, mask) More...
#include <ConvolveVariable.h>
Public Member Functions | |
ConvolveVariable () | |
Default constructor for persistence. | |
ConvolveVariable (Variable *input, Variable *mask) | |
virtual string | classname () const |
virtual OptionList & | getOptionList () const |
virtual OptionMap & | getOptionMap () const |
virtual RemoteMethodMap & | getRemoteMethodMap () const |
virtual ConvolveVariable * | deepCopy (CopiesMap &copies) const |
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_ () |
ConvolveVariable. | |
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 BinaryVariable | inherited |
A convolve var; equals convolve(input, mask)
Definition at line 54 of file ConvolveVariable.h.
typedef BinaryVariable PLearn::ConvolveVariable::inherited [private] |
Reimplemented from PLearn::BinaryVariable.
Definition at line 56 of file ConvolveVariable.h.
PLearn::ConvolveVariable::ConvolveVariable | ( | ) | [inline] |
Definition at line 55 of file ConvolveVariable.cc.
: inherited(input, mask, input->length()-mask->length()+1, input->width()-mask->width()+1) {}
string PLearn::ConvolveVariable::_classname_ | ( | ) | [static] |
Reimplemented from PLearn::BinaryVariable.
Definition at line 53 of file ConvolveVariable.cc.
OptionList & PLearn::ConvolveVariable::_getOptionList_ | ( | ) | [static] |
Reimplemented from PLearn::BinaryVariable.
Definition at line 53 of file ConvolveVariable.cc.
RemoteMethodMap & PLearn::ConvolveVariable::_getRemoteMethodMap_ | ( | ) | [static] |
Reimplemented from PLearn::BinaryVariable.
Definition at line 53 of file ConvolveVariable.cc.
Reimplemented from PLearn::BinaryVariable.
Definition at line 53 of file ConvolveVariable.cc.
Object * PLearn::ConvolveVariable::_new_instance_for_typemap_ | ( | ) | [static] |
Reimplemented from PLearn::Object.
Definition at line 53 of file ConvolveVariable.cc.
StaticInitializer ConvolveVariable::_static_initializer_ & PLearn::ConvolveVariable::_static_initialize_ | ( | ) | [static] |
Reimplemented from PLearn::BinaryVariable.
Definition at line 53 of file ConvolveVariable.cc.
void PLearn::ConvolveVariable::bprop | ( | ) | [virtual] |
Implements PLearn::Variable.
Definition at line 76 of file ConvolveVariable.cc.
References c, i, PLearn::BinaryVariable::input1, PLearn::BinaryVariable::input2, j, PLearn::Var::length(), PLearn::Variable::length(), PLearn::Variable::matGradient, PLearn::Variable::width(), and PLearn::Var::width().
{ for(int i=0; i<length(); i++) // size of matGradient for(int j=0; j<width(); j++) { real* input1valueptr = input1->matValue[i]+j; real* input2valueptr = input2->matValue.data(); real thisgradient = matGradient(i,j); real* input1gradientptr = input1->matGradient[i]+j; real* input2gradientptr = input2->matGradient.data(); for(int l=0; l<input2->length(); l++, input1valueptr += input1->matValue.mod(), input2valueptr += input2->matValue.mod(), input1gradientptr += input1->matGradient.mod(), input2gradientptr += input2->matGradient.mod()) for(int c=0; c<input2->width(); c++) { input1gradientptr[c] += thisgradient * input2valueptr[c]; input2gradientptr[c] += thisgradient * input1valueptr[c]; } } }
string PLearn::ConvolveVariable::classname | ( | ) | const [virtual] |
Reimplemented from PLearn::Object.
Definition at line 53 of file ConvolveVariable.cc.
static const PPath& PLearn::ConvolveVariable::declaringFile | ( | ) | [inline, static] |
Reimplemented from PLearn::BinaryVariable.
Definition at line 63 of file ConvolveVariable.h.
{ return new ConvolveVariable(input, mask); }
ConvolveVariable * PLearn::ConvolveVariable::deepCopy | ( | CopiesMap & | copies | ) | const [virtual] |
Reimplemented from PLearn::BinaryVariable.
Definition at line 53 of file ConvolveVariable.cc.
void PLearn::ConvolveVariable::fprop | ( | ) | [virtual] |
compute output given input
Implements PLearn::Variable.
Definition at line 70 of file ConvolveVariable.cc.
References PLearn::convolve(), PLearn::BinaryVariable::input1, PLearn::BinaryVariable::input2, and PLearn::Variable::matValue.
OptionList & PLearn::ConvolveVariable::getOptionList | ( | ) | const [virtual] |
Reimplemented from PLearn::Object.
Definition at line 53 of file ConvolveVariable.cc.
OptionMap & PLearn::ConvolveVariable::getOptionMap | ( | ) | const [virtual] |
Reimplemented from PLearn::Object.
Definition at line 53 of file ConvolveVariable.cc.
RemoteMethodMap & PLearn::ConvolveVariable::getRemoteMethodMap | ( | ) | const [virtual] |
Reimplemented from PLearn::Object.
Definition at line 53 of file ConvolveVariable.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 60 of file ConvolveVariable.cc.
References PLearn::BinaryVariable::input1, PLearn::BinaryVariable::input2, PLearn::Var::length(), and PLearn::Var::width().
{ if (input1 && input2) { l = input1->length() - input2->length() + 1; w = input1->width() - input2->width() + 1; } else l = w = 0; }
void PLearn::ConvolveVariable::symbolicBprop | ( | ) | [virtual] |
compute a piece of new Var graph that represents the symbolic derivative of this Var
Reimplemented from PLearn::Variable.
Definition at line 100 of file ConvolveVariable.cc.
References PLERROR.
{ PLERROR("ConvolveVariable::symbolicBprop() not yet implemented"); }
Reimplemented from PLearn::BinaryVariable.
Definition at line 63 of file ConvolveVariable.h.