PLearn 0.1
|
#include <TanhVariable.h>
Public Member Functions | |
TanhVariable () | |
Default constructor for persistence. | |
TanhVariable (Variable *input) | |
virtual string | classname () const |
virtual OptionList & | getOptionList () const |
virtual OptionMap & | getOptionMap () const |
virtual RemoteMethodMap & | getRemoteMethodMap () const |
virtual TanhVariable * | 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 () |
Nothing to do by default. | |
virtual void | bprop () |
Nothing to do by default. | |
virtual void | bbprop () |
compute an approximation to diag(d^2/dinput^2) given diag(d^2/doutput^2), with diag(d^2/dinput^2) ~=~ (doutput/dinput)' diag(d^2/doutput^2) (doutput/dinput) In particular: if 'C' depends on 'y' and 'y' depends on x ... | |
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_ () |
TanhVariable. | |
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 UnaryVariable | inherited |
* Simple unary transforms... *
Definition at line 54 of file TanhVariable.h.
typedef UnaryVariable PLearn::TanhVariable::inherited [private] |
Reimplemented from PLearn::UnaryVariable.
Definition at line 56 of file TanhVariable.h.
PLearn::TanhVariable::TanhVariable | ( | ) | [inline] |
PLearn::TanhVariable::TanhVariable | ( | Variable * | input | ) |
string PLearn::TanhVariable::_classname_ | ( | ) | [static] |
Reimplemented from PLearn::UnaryVariable.
Definition at line 54 of file TanhVariable.cc.
OptionList & PLearn::TanhVariable::_getOptionList_ | ( | ) | [static] |
Reimplemented from PLearn::UnaryVariable.
Definition at line 54 of file TanhVariable.cc.
RemoteMethodMap & PLearn::TanhVariable::_getRemoteMethodMap_ | ( | ) | [static] |
Reimplemented from PLearn::UnaryVariable.
Definition at line 54 of file TanhVariable.cc.
Reimplemented from PLearn::UnaryVariable.
Definition at line 54 of file TanhVariable.cc.
Object * PLearn::TanhVariable::_new_instance_for_typemap_ | ( | ) | [static] |
Reimplemented from PLearn::UnaryVariable.
Definition at line 54 of file TanhVariable.cc.
StaticInitializer TanhVariable::_static_initializer_ & PLearn::TanhVariable::_static_initialize_ | ( | ) | [static] |
Reimplemented from PLearn::UnaryVariable.
Definition at line 54 of file TanhVariable.cc.
void PLearn::TanhVariable::bbprop | ( | ) | [virtual] |
compute an approximation to diag(d^2/dinput^2) given diag(d^2/doutput^2), with diag(d^2/dinput^2) ~=~ (doutput/dinput)' diag(d^2/doutput^2) (doutput/dinput) In particular: if 'C' depends on 'y' and 'y' depends on x ...
d^2C/dx^2 = d^2C/dy^2 * (dy/dx)^2 + dC/dy * d^2y/dx^2 (diaghessian) (gradient)
Reimplemented from PLearn::Variable.
Definition at line 90 of file TanhVariable.cc.
References PLearn::Variable::diaghessiandata, i, PLearn::UnaryVariable::input, PLearn::Var::length(), PLearn::Variable::nelems(), and PLearn::Variable::valuedata.
{ if (input->diaghessian.length()==0) input->resizeDiagHessian(); for(int i=0; i<nelems(); i++) { real yi=valuedata[i]; real fprime=(1-yi*yi); input->diaghessiandata[i] += diaghessiandata[i] * fprime * fprime; } }
void PLearn::TanhVariable::bprop | ( | ) | [virtual] |
Nothing to do by default.
Reimplemented from PLearn::UnaryVariable.
Definition at line 79 of file TanhVariable.cc.
References PLearn::Variable::gradientdata, i, PLearn::UnaryVariable::input, PLearn::Variable::nelems(), PLearn::square(), and PLearn::Variable::valuedata.
{ int l = nelems(); real* inputgradientptr = input->gradientdata; real* gradientptr = gradientdata; real* valueptr = valuedata; for(int i=0; i<l; i++) *inputgradientptr++ += *gradientptr++ * (1.0-square(*valueptr++)); }
string PLearn::TanhVariable::classname | ( | ) | const [virtual] |
Reimplemented from PLearn::UnaryVariable.
Definition at line 54 of file TanhVariable.cc.
static const PPath& PLearn::TanhVariable::declaringFile | ( | ) | [inline, static] |
Reimplemented from PLearn::UnaryVariable.
Definition at line 63 of file TanhVariable.h.
{ return new TanhVariable(v); }
TanhVariable * PLearn::TanhVariable::deepCopy | ( | CopiesMap & | copies | ) | const [virtual] |
Reimplemented from PLearn::UnaryVariable.
Definition at line 54 of file TanhVariable.cc.
void PLearn::TanhVariable::fprop | ( | ) | [virtual] |
Nothing to do by default.
Reimplemented from PLearn::UnaryVariable.
Definition at line 69 of file TanhVariable.cc.
References i, PLearn::UnaryVariable::input, PLearn::Variable::nelems(), PLearn::tanh(), and PLearn::Variable::valuedata.
{ int l = nelems(); real* inputptr = input->valuedata; real* ptr = valuedata; for(int i=0; i<l; i++) *ptr++ = tanh(*inputptr++); }
OptionList & PLearn::TanhVariable::getOptionList | ( | ) | const [virtual] |
Reimplemented from PLearn::UnaryVariable.
Definition at line 54 of file TanhVariable.cc.
OptionMap & PLearn::TanhVariable::getOptionMap | ( | ) | const [virtual] |
Reimplemented from PLearn::UnaryVariable.
Definition at line 54 of file TanhVariable.cc.
RemoteMethodMap & PLearn::TanhVariable::getRemoteMethodMap | ( | ) | const [virtual] |
Reimplemented from PLearn::UnaryVariable.
Definition at line 54 of file TanhVariable.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 TanhVariable.cc.
References PLearn::UnaryVariable::input, PLearn::Var::length(), and PLearn::Var::width().
void PLearn::TanhVariable::rfprop | ( | ) | [virtual] |
Reimplemented from PLearn::Variable.
Definition at line 111 of file TanhVariable.cc.
References i, PLearn::UnaryVariable::input, PLearn::TVec< T >::length(), PLearn::Variable::nelems(), PLearn::UnaryVariable::resizeRValue(), PLearn::Variable::rValue, PLearn::Variable::rvaluedata, PLearn::square(), and PLearn::Variable::valuedata.
{ if (rValue.length()==0) resizeRValue(); int l = nelems(); real* inputptr = input->rvaluedata; real* valueptr = valuedata; real* ptr = rvaluedata; for(int i=0; i<l; i++) *ptr++ = *inputptr++ * (1.0 - square(*valueptr++)); }
void PLearn::TanhVariable::symbolicBprop | ( | ) | [virtual] |
compute a piece of new Var graph that represents the symbolic derivative of this Var
Reimplemented from PLearn::Variable.
Definition at line 103 of file TanhVariable.cc.
References PLearn::Variable::g, PLearn::UnaryVariable::input, and PLearn::square().
Reimplemented from PLearn::UnaryVariable.
Definition at line 63 of file TanhVariable.h.