PLearn 0.1
|
#include <SoftmaxVariable.h>
Public Member Functions | |
SoftmaxVariable () | |
Default constructor for persistence. | |
SoftmaxVariable (Variable *input) | |
virtual string | classname () const |
virtual OptionList & | getOptionList () const |
virtual OptionMap & | getOptionMap () const |
virtual RemoteMethodMap & | getRemoteMethodMap () const |
virtual SoftmaxVariable * | 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_ () |
SoftmaxVariable. | |
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 53 of file SoftmaxVariable.h.
typedef UnaryVariable PLearn::SoftmaxVariable::inherited [private] |
Reimplemented from PLearn::UnaryVariable.
Definition at line 55 of file SoftmaxVariable.h.
PLearn::SoftmaxVariable::SoftmaxVariable | ( | ) | [inline] |
PLearn::SoftmaxVariable::SoftmaxVariable | ( | Variable * | input | ) |
string PLearn::SoftmaxVariable::_classname_ | ( | ) | [static] |
Reimplemented from PLearn::UnaryVariable.
Definition at line 55 of file SoftmaxVariable.cc.
OptionList & PLearn::SoftmaxVariable::_getOptionList_ | ( | ) | [static] |
Reimplemented from PLearn::UnaryVariable.
Definition at line 55 of file SoftmaxVariable.cc.
RemoteMethodMap & PLearn::SoftmaxVariable::_getRemoteMethodMap_ | ( | ) | [static] |
Reimplemented from PLearn::UnaryVariable.
Definition at line 55 of file SoftmaxVariable.cc.
Reimplemented from PLearn::UnaryVariable.
Definition at line 55 of file SoftmaxVariable.cc.
Object * PLearn::SoftmaxVariable::_new_instance_for_typemap_ | ( | ) | [static] |
Reimplemented from PLearn::UnaryVariable.
Definition at line 55 of file SoftmaxVariable.cc.
StaticInitializer SoftmaxVariable::_static_initializer_ & PLearn::SoftmaxVariable::_static_initialize_ | ( | ) | [static] |
Reimplemented from PLearn::UnaryVariable.
Definition at line 55 of file SoftmaxVariable.cc.
void PLearn::SoftmaxVariable::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 92 of file SoftmaxVariable.cc.
References PLERROR.
{ PLERROR("SofmaxVariable::bbprop() not implemented"); }
void PLearn::SoftmaxVariable::bprop | ( | ) | [virtual] |
Nothing to do by default.
Reimplemented from PLearn::UnaryVariable.
Definition at line 76 of file SoftmaxVariable.cc.
References PLearn::Variable::gradientdata, i, PLearn::UnaryVariable::input, PLearn::Variable::nelems(), and PLearn::Variable::valuedata.
{ for(int i=0; i<input->nelems(); i++) { real vali = valuedata[i]; for(int k=0; k<nelems(); k++) { if(k!=i) input->gradientdata[i] -= gradientdata[k]*vali*valuedata[k]; else input->gradientdata[i] += gradientdata[i]*vali*(1.-vali); } } }
string PLearn::SoftmaxVariable::classname | ( | ) | const [virtual] |
Reimplemented from PLearn::UnaryVariable.
Definition at line 55 of file SoftmaxVariable.cc.
static const PPath& PLearn::SoftmaxVariable::declaringFile | ( | ) | [inline, static] |
SoftmaxVariable * PLearn::SoftmaxVariable::deepCopy | ( | CopiesMap & | copies | ) | const [virtual] |
Reimplemented from PLearn::UnaryVariable.
Definition at line 55 of file SoftmaxVariable.cc.
void PLearn::SoftmaxVariable::fprop | ( | ) | [virtual] |
Nothing to do by default.
Reimplemented from PLearn::UnaryVariable.
Definition at line 70 of file SoftmaxVariable.cc.
References PLearn::UnaryVariable::input, PLearn::softmax(), and PLearn::Variable::value.
OptionList & PLearn::SoftmaxVariable::getOptionList | ( | ) | const [virtual] |
Reimplemented from PLearn::UnaryVariable.
Definition at line 55 of file SoftmaxVariable.cc.
OptionMap & PLearn::SoftmaxVariable::getOptionMap | ( | ) | const [virtual] |
Reimplemented from PLearn::UnaryVariable.
Definition at line 55 of file SoftmaxVariable.cc.
RemoteMethodMap & PLearn::SoftmaxVariable::getRemoteMethodMap | ( | ) | const [virtual] |
Reimplemented from PLearn::UnaryVariable.
Definition at line 55 of file SoftmaxVariable.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 61 of file SoftmaxVariable.cc.
References PLearn::UnaryVariable::input, PLearn::Var::length(), and PLearn::Var::width().
void PLearn::SoftmaxVariable::rfprop | ( | ) | [virtual] |
Reimplemented from PLearn::Variable.
Definition at line 105 of file SoftmaxVariable.cc.
References i, PLearn::UnaryVariable::input, PLearn::TVec< T >::length(), PLearn::UnaryVariable::resizeRValue(), PLearn::Variable::rValue, PLearn::Variable::rvaluedata, and PLearn::Variable::valuedata.
{ if (rValue.length()==0) resizeRValue(); for(int i=0; i<input->nelems(); i++) { real vali = valuedata[i]; rvaluedata[i] = vali * (1 - vali) * input->rvaluedata[i]; } }
void PLearn::SoftmaxVariable::symbolicBprop | ( | ) | [virtual] |
compute a piece of new Var graph that represents the symbolic derivative of this Var
Reimplemented from PLearn::Variable.
Definition at line 98 of file SoftmaxVariable.cc.
References PLERROR.
{ PLERROR("SofmaxVariable::symbolicBprop() not implemented"); }
Reimplemented from PLearn::UnaryVariable.
Definition at line 62 of file SoftmaxVariable.h.