PLearn 0.1
|
#include <ThresholdBpropVariable.h>
Public Member Functions | |
ThresholdBpropVariable () | |
Default constructor for persistence. | |
ThresholdBpropVariable (Variable *input, real the_gradient_threshold_factor=0.0) | |
virtual string | classname () const |
virtual OptionList & | getOptionList () const |
virtual OptionMap & | getOptionMap () const |
virtual RemoteMethodMap & | getRemoteMethodMap () const |
virtual ThresholdBpropVariable * | 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 () |
Nothing to do by default. | |
virtual void | bprop () |
Nothing to do by default. | |
Static Public Member Functions | |
static string | _classname_ () |
ThresholdBpropVariable. | |
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 void | declareOptions (OptionList &ol) |
Declare options (data fields) for the class. | |
Public Attributes | |
real | gradient_threshold_factor |
Static Public Attributes | |
static StaticInitializer | _static_initializer_ |
Protected Member Functions | |
void | build_ () |
Object-specific post-constructor. | |
Private Types | |
typedef UnaryVariable | inherited |
Variable that copies its unique input, and can completely block the flow of gradient backward, or optionally let if flow partially (with an optional coefficient), i.e. fprop: output = input bprop: dC/dinput = sign(dC/doutput) min(abs(input*gradient_threshold_factor),abs(dC/doutput))
Definition at line 61 of file ThresholdBpropVariable.h.
typedef UnaryVariable PLearn::ThresholdBpropVariable::inherited [private] |
Reimplemented from PLearn::UnaryVariable.
Definition at line 63 of file ThresholdBpropVariable.h.
PLearn::ThresholdBpropVariable::ThresholdBpropVariable | ( | ) | [inline] |
Default constructor for persistence.
Definition at line 70 of file ThresholdBpropVariable.h.
: gradient_threshold_factor(0) {}
PLearn::ThresholdBpropVariable::ThresholdBpropVariable | ( | Variable * | input, |
real | the_gradient_threshold_factor = 0.0 |
||
) |
Definition at line 61 of file ThresholdBpropVariable.cc.
References build_().
: inherited(input, input->length(), input->width()), gradient_threshold_factor(the_gradient_threshold_factor) { build_(); }
string PLearn::ThresholdBpropVariable::_classname_ | ( | ) | [static] |
Reimplemented from PLearn::UnaryVariable.
Definition at line 59 of file ThresholdBpropVariable.cc.
OptionList & PLearn::ThresholdBpropVariable::_getOptionList_ | ( | ) | [static] |
Reimplemented from PLearn::UnaryVariable.
Definition at line 59 of file ThresholdBpropVariable.cc.
RemoteMethodMap & PLearn::ThresholdBpropVariable::_getRemoteMethodMap_ | ( | ) | [static] |
Reimplemented from PLearn::UnaryVariable.
Definition at line 59 of file ThresholdBpropVariable.cc.
Reimplemented from PLearn::UnaryVariable.
Definition at line 59 of file ThresholdBpropVariable.cc.
Object * PLearn::ThresholdBpropVariable::_new_instance_for_typemap_ | ( | ) | [static] |
Reimplemented from PLearn::UnaryVariable.
Definition at line 59 of file ThresholdBpropVariable.cc.
StaticInitializer ThresholdBpropVariable::_static_initializer_ & PLearn::ThresholdBpropVariable::_static_initialize_ | ( | ) | [static] |
Reimplemented from PLearn::UnaryVariable.
Definition at line 59 of file ThresholdBpropVariable.cc.
void PLearn::ThresholdBpropVariable::bprop | ( | ) | [virtual] |
Nothing to do by default.
Reimplemented from PLearn::UnaryVariable.
Definition at line 105 of file ThresholdBpropVariable.cc.
References PLearn::abs(), gradient_threshold_factor, PLearn::Variable::gradientdata, and PLearn::UnaryVariable::input.
{ if(gradient_threshold_factor!=0) { for(int k=0; k<input->nelems(); k++) if(abs(gradientdata[k]) > abs(gradient_threshold_factor * input->valuedata[k])) input->gradientdata[k] += abs(gradient_threshold_factor * input->valuedata[k]) * (gradientdata[k]>0 ? 1 : -1); else input->gradientdata[k] += gradientdata[k]; } }
void PLearn::ThresholdBpropVariable::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::UnaryVariable.
Definition at line 69 of file ThresholdBpropVariable.cc.
References PLearn::UnaryVariable::build(), and build_().
{ inherited::build(); build_(); }
void PLearn::ThresholdBpropVariable::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::UnaryVariable.
Definition at line 76 of file ThresholdBpropVariable.cc.
Referenced by build(), and ThresholdBpropVariable().
{ }
string PLearn::ThresholdBpropVariable::classname | ( | ) | const [virtual] |
Reimplemented from PLearn::UnaryVariable.
Definition at line 59 of file ThresholdBpropVariable.cc.
void PLearn::ThresholdBpropVariable::declareOptions | ( | OptionList & | ol | ) | [static] |
Declare options (data fields) for the class.
Redefine this in subclasses: call declareOption
(...) for each option, and then call inherited::declareOptions(options)
. Please call the inherited
method AT THE END to get the options listed in a consistent order (from most recently defined to least recently defined).
static void MyDerivedClass::declareOptions(OptionList& ol) { declareOption(ol, "inputsize", &MyObject::inputsize_, OptionBase::buildoption, "The size of the input; it must be provided"); declareOption(ol, "weights", &MyObject::weights, OptionBase::learntoption, "The learned model weights"); inherited::declareOptions(ol); }
ol | List of options that is progressively being constructed for the current class. |
Reimplemented from PLearn::UnaryVariable.
Definition at line 81 of file ThresholdBpropVariable.cc.
References PLearn::OptionBase::buildoption, PLearn::declareOption(), PLearn::UnaryVariable::declareOptions(), and gradient_threshold_factor.
{ declareOption(ol, "gradient_threshold_factor", &ThresholdBpropVariable::gradient_threshold_factor, OptionBase::buildoption, "Factor by which the value of the variable is multiplied to obtain the absolute threshold\n" "on the gradient."); inherited::declareOptions(ol); }
static const PPath& PLearn::ThresholdBpropVariable::declaringFile | ( | ) | [inline, static] |
Reimplemented from PLearn::UnaryVariable.
Definition at line 75 of file ThresholdBpropVariable.h.
: void build_();
ThresholdBpropVariable * PLearn::ThresholdBpropVariable::deepCopy | ( | CopiesMap & | copies | ) | const [virtual] |
Reimplemented from PLearn::UnaryVariable.
Definition at line 59 of file ThresholdBpropVariable.cc.
void PLearn::ThresholdBpropVariable::fprop | ( | ) | [virtual] |
Nothing to do by default.
Reimplemented from PLearn::UnaryVariable.
Definition at line 98 of file ThresholdBpropVariable.cc.
References PLearn::UnaryVariable::input, and PLearn::Variable::valuedata.
OptionList & PLearn::ThresholdBpropVariable::getOptionList | ( | ) | const [virtual] |
Reimplemented from PLearn::UnaryVariable.
Definition at line 59 of file ThresholdBpropVariable.cc.
OptionMap & PLearn::ThresholdBpropVariable::getOptionMap | ( | ) | const [virtual] |
Reimplemented from PLearn::UnaryVariable.
Definition at line 59 of file ThresholdBpropVariable.cc.
RemoteMethodMap & PLearn::ThresholdBpropVariable::getRemoteMethodMap | ( | ) | const [virtual] |
Reimplemented from PLearn::UnaryVariable.
Definition at line 59 of file ThresholdBpropVariable.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 89 of file ThresholdBpropVariable.cc.
References PLearn::UnaryVariable::input, PLearn::Var::length(), and PLearn::Var::width().
Reimplemented from PLearn::UnaryVariable.
Definition at line 75 of file ThresholdBpropVariable.h.
Definition at line 66 of file ThresholdBpropVariable.h.
Referenced by bprop(), and declareOptions().