PLearn 0.1
|
#include <LogSoftmaxVariable.h>
Public Member Functions | |
LogSoftmaxVariable () | |
Default constructor. | |
LogSoftmaxVariable (Variable *input, bool call_build_=true) | |
Convenience constructor. | |
virtual string | classname () const |
virtual OptionList & | getOptionList () const |
virtual OptionMap & | getOptionMap () const |
virtual RemoteMethodMap & | getRemoteMethodMap () const |
virtual LogSoftmaxVariable * | 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 | build () |
Post-constructor. | |
Static Public Member Functions | |
static string | _classname_ () |
LogSoftmaxVariable. | |
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 |
Private Member Functions | |
void | build_ () |
Object-specific post-constructor. |
Definition at line 52 of file LogSoftmaxVariable.h.
typedef UnaryVariable PLearn::LogSoftmaxVariable::inherited [private] |
Reimplemented from PLearn::UnaryVariable.
Definition at line 54 of file LogSoftmaxVariable.h.
PLearn::LogSoftmaxVariable::LogSoftmaxVariable | ( | ) | [inline] |
string PLearn::LogSoftmaxVariable::_classname_ | ( | ) | [static] |
Reimplemented from PLearn::UnaryVariable.
Definition at line 55 of file LogSoftmaxVariable.cc.
OptionList & PLearn::LogSoftmaxVariable::_getOptionList_ | ( | ) | [static] |
Reimplemented from PLearn::UnaryVariable.
Definition at line 55 of file LogSoftmaxVariable.cc.
RemoteMethodMap & PLearn::LogSoftmaxVariable::_getRemoteMethodMap_ | ( | ) | [static] |
Reimplemented from PLearn::UnaryVariable.
Definition at line 55 of file LogSoftmaxVariable.cc.
Reimplemented from PLearn::UnaryVariable.
Definition at line 55 of file LogSoftmaxVariable.cc.
Object * PLearn::LogSoftmaxVariable::_new_instance_for_typemap_ | ( | ) | [static] |
Reimplemented from PLearn::UnaryVariable.
Definition at line 55 of file LogSoftmaxVariable.cc.
StaticInitializer LogSoftmaxVariable::_static_initializer_ & PLearn::LogSoftmaxVariable::_static_initialize_ | ( | ) | [static] |
Reimplemented from PLearn::UnaryVariable.
Definition at line 55 of file LogSoftmaxVariable.cc.
void PLearn::LogSoftmaxVariable::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 113 of file LogSoftmaxVariable.cc.
References PLERROR.
{ PLERROR("LogSofmaxVariable::bbprop() not implemented"); }
void PLearn::LogSoftmaxVariable::bprop | ( | ) | [virtual] |
Nothing to do by default.
Reimplemented from PLearn::UnaryVariable.
Definition at line 101 of file LogSoftmaxVariable.cc.
References PLearn::Variable::gradientdata, i, PLearn::UnaryVariable::input, PLearn::Variable::nelems(), PLearn::safeexp(), PLearn::sum(), and PLearn::Variable::valuedata.
{ for (int i = 0; i < input->nelems(); ++i) { real sum = 0.; for (int k = 0; k < nelems(); ++k) sum += gradientdata[k]; input->gradientdata[i] += gradientdata[i] - sum * safeexp(valuedata[i]); } }
void PLearn::LogSoftmaxVariable::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 70 of file LogSoftmaxVariable.cc.
References PLearn::UnaryVariable::build(), and build_().
{ inherited::build(); build_(); }
void PLearn::LogSoftmaxVariable::build_ | ( | ) | [private] |
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 79 of file LogSoftmaxVariable.cc.
Referenced by build(), and LogSoftmaxVariable().
{
// Nothing to do here.
}
string PLearn::LogSoftmaxVariable::classname | ( | ) | const [virtual] |
Reimplemented from PLearn::UnaryVariable.
Definition at line 55 of file LogSoftmaxVariable.cc.
static const PPath& PLearn::LogSoftmaxVariable::declaringFile | ( | ) | [inline, static] |
LogSoftmaxVariable * PLearn::LogSoftmaxVariable::deepCopy | ( | CopiesMap & | copies | ) | const [virtual] |
Reimplemented from PLearn::UnaryVariable.
Definition at line 55 of file LogSoftmaxVariable.cc.
void PLearn::LogSoftmaxVariable::fprop | ( | ) | [virtual] |
Nothing to do by default.
Reimplemented from PLearn::UnaryVariable.
Definition at line 94 of file LogSoftmaxVariable.cc.
References PLearn::UnaryVariable::input, PLearn::log_softmax(), and PLearn::Variable::value.
{ log_softmax(input->value, value); }
OptionList & PLearn::LogSoftmaxVariable::getOptionList | ( | ) | const [virtual] |
Reimplemented from PLearn::UnaryVariable.
Definition at line 55 of file LogSoftmaxVariable.cc.
OptionMap & PLearn::LogSoftmaxVariable::getOptionMap | ( | ) | const [virtual] |
Reimplemented from PLearn::UnaryVariable.
Definition at line 55 of file LogSoftmaxVariable.cc.
RemoteMethodMap & PLearn::LogSoftmaxVariable::getRemoteMethodMap | ( | ) | const [virtual] |
Reimplemented from PLearn::UnaryVariable.
Definition at line 55 of file LogSoftmaxVariable.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 84 of file LogSoftmaxVariable.cc.
References PLearn::UnaryVariable::input, PLearn::Var::length(), and PLearn::Var::width().
void PLearn::LogSoftmaxVariable::symbolicBprop | ( | ) | [virtual] |
compute a piece of new Var graph that represents the symbolic derivative of this Var
Reimplemented from PLearn::Variable.
Definition at line 120 of file LogSoftmaxVariable.cc.
References PLERROR.
{ PLERROR("LogSofmaxVariable::symbolicBprop() not implemented"); }
Reimplemented from PLearn::UnaryVariable.
Definition at line 64 of file LogSoftmaxVariable.h.