PLearn 0.1
|
#include <SigmoidVariable.h>
Public Member Functions | |
SigmoidVariable () | |
Default constructor for persistence. | |
SigmoidVariable (Variable *input) | |
virtual string | classname () const |
virtual OptionList & | getOptionList () const |
virtual OptionMap & | getOptionMap () const |
virtual RemoteMethodMap & | getRemoteMethodMap () const |
virtual SigmoidVariable * | 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_ () |
SigmoidVariable. | |
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 |
Definition at line 52 of file SigmoidVariable.h.
typedef UnaryVariable PLearn::SigmoidVariable::inherited [private] |
Reimplemented from PLearn::UnaryVariable.
Definition at line 54 of file SigmoidVariable.h.
PLearn::SigmoidVariable::SigmoidVariable | ( | ) | [inline] |
PLearn::SigmoidVariable::SigmoidVariable | ( | Variable * | input | ) |
string PLearn::SigmoidVariable::_classname_ | ( | ) | [static] |
Reimplemented from PLearn::UnaryVariable.
Definition at line 54 of file SigmoidVariable.cc.
OptionList & PLearn::SigmoidVariable::_getOptionList_ | ( | ) | [static] |
Reimplemented from PLearn::UnaryVariable.
Definition at line 54 of file SigmoidVariable.cc.
RemoteMethodMap & PLearn::SigmoidVariable::_getRemoteMethodMap_ | ( | ) | [static] |
Reimplemented from PLearn::UnaryVariable.
Definition at line 54 of file SigmoidVariable.cc.
Reimplemented from PLearn::UnaryVariable.
Definition at line 54 of file SigmoidVariable.cc.
Object * PLearn::SigmoidVariable::_new_instance_for_typemap_ | ( | ) | [static] |
Reimplemented from PLearn::UnaryVariable.
Definition at line 54 of file SigmoidVariable.cc.
StaticInitializer SigmoidVariable::_static_initializer_ & PLearn::SigmoidVariable::_static_initialize_ | ( | ) | [static] |
Reimplemented from PLearn::UnaryVariable.
Definition at line 54 of file SigmoidVariable.cc.
void PLearn::SigmoidVariable::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 93 of file SigmoidVariable.cc.
References PLearn::Variable::gradientdata, 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 = yi*(1-yi); input->gradientdata[i] += gradientdata[i] * fprime * fprime; } }
void PLearn::SigmoidVariable::bprop | ( | ) | [virtual] |
Nothing to do by default.
Reimplemented from PLearn::UnaryVariable.
Definition at line 79 of file SigmoidVariable.cc.
References PLearn::Variable::gradientdata, i, PLearn::UnaryVariable::input, PLearn::Variable::nelems(), and PLearn::Variable::valuedata.
{ int l = nelems(); real* inputgradientptr = input->gradientdata; real* gradientptr = gradientdata; real* valueptr = valuedata; for(int i=0; i<l; i++) { real val = *valueptr++; *inputgradientptr++ += *gradientptr++ * val*(1.0-val); } }
string PLearn::SigmoidVariable::classname | ( | ) | const [virtual] |
Reimplemented from PLearn::UnaryVariable.
Definition at line 54 of file SigmoidVariable.cc.
static const PPath& PLearn::SigmoidVariable::declaringFile | ( | ) | [inline, static] |
Reimplemented from PLearn::UnaryVariable.
Definition at line 61 of file SigmoidVariable.h.
{ return new SigmoidVariable(v); }
SigmoidVariable * PLearn::SigmoidVariable::deepCopy | ( | CopiesMap & | copies | ) | const [virtual] |
Reimplemented from PLearn::UnaryVariable.
Definition at line 54 of file SigmoidVariable.cc.
void PLearn::SigmoidVariable::fprop | ( | ) | [virtual] |
Nothing to do by default.
Reimplemented from PLearn::UnaryVariable.
Definition at line 69 of file SigmoidVariable.cc.
References i, PLearn::UnaryVariable::input, PLearn::Variable::nelems(), PLearn::sigmoid(), and PLearn::Variable::valuedata.
{ int l = nelems(); real* valueptr = valuedata; real* inputvalueptr = input->valuedata; for(int i=0; i<l; i++) *valueptr++ = sigmoid(*inputvalueptr++); }
OptionList & PLearn::SigmoidVariable::getOptionList | ( | ) | const [virtual] |
Reimplemented from PLearn::UnaryVariable.
Definition at line 54 of file SigmoidVariable.cc.
OptionMap & PLearn::SigmoidVariable::getOptionMap | ( | ) | const [virtual] |
Reimplemented from PLearn::UnaryVariable.
Definition at line 54 of file SigmoidVariable.cc.
RemoteMethodMap & PLearn::SigmoidVariable::getRemoteMethodMap | ( | ) | const [virtual] |
Reimplemented from PLearn::UnaryVariable.
Definition at line 54 of file SigmoidVariable.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 SigmoidVariable.cc.
References PLearn::UnaryVariable::input, PLearn::Var::length(), and PLearn::Var::width().
void PLearn::SigmoidVariable::rfprop | ( | ) | [virtual] |
Reimplemented from PLearn::Variable.
Definition at line 114 of file SigmoidVariable.cc.
References i, PLearn::UnaryVariable::input, PLearn::TVec< T >::length(), PLearn::Variable::nelems(), PLearn::UnaryVariable::resizeRValue(), PLearn::Variable::rValue, PLearn::Variable::rvaluedata, and PLearn::Variable::valuedata.
{ if (rValue.length()==0) resizeRValue(); int l = nelems(); real* inputptr = input->rvaluedata; real* inputvalueptr = valuedata; real* ptr = rvaluedata; for(int i=0; i<l; i++) { real val = *inputvalueptr++; *ptr++ = *inputptr++ * val * (1.0 - val); } }
void PLearn::SigmoidVariable::symbolicBprop | ( | ) | [virtual] |
compute a piece of new Var graph that represents the symbolic derivative of this Var
Reimplemented from PLearn::Variable.
Definition at line 106 of file SigmoidVariable.cc.
References PLearn::Variable::g, and PLearn::UnaryVariable::input.
Reimplemented from PLearn::UnaryVariable.
Definition at line 61 of file SigmoidVariable.h.