PLearn 0.1
|
The first sentence should be a BRIEF DESCRIPTION of what the class does. More...
#include <SumEntropyOfCategoricals.h>
Public Member Functions | |
SumEntropyOfCategoricals () | |
### declare public option fields (such as build options) here Start your comments with Doxygen-compatible comments such as //! | |
SumEntropyOfCategoricals (Variable *input) | |
Constructor initializing from input variable. | |
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 string | classname () const |
virtual OptionList & | getOptionList () const |
virtual OptionMap & | getOptionMap () const |
virtual RemoteMethodMap & | getRemoteMethodMap () const |
virtual SumEntropyOfCategoricals * | deepCopy (CopiesMap &copies) const |
virtual void | build () |
Post-constructor. | |
virtual void | makeDeepCopyFromShallowCopy (CopiesMap &copies) |
Transforms a shallow copy into a deep copy. | |
Static Public Member Functions | |
static string | _classname_ () |
SumEntropyOfCategoricals. | |
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_ |
Static Protected Member Functions | |
static void | declareOptions (OptionList &ol) |
Declares the class options. | |
Private Types | |
typedef UnaryVariable | inherited |
Private Member Functions | |
void | build_ () |
This does the actual building. |
The first sentence should be a BRIEF DESCRIPTION of what the class does.
* SumEntropyOfCategoricals * Place the rest of the class programmer documentation here. Doxygen supports Javadoc-style comments. See http://www.doxygen.org/manual.html
Definition at line 60 of file SumEntropyOfCategoricals.h.
typedef UnaryVariable PLearn::SumEntropyOfCategoricals::inherited [private] |
Reimplemented from PLearn::UnaryVariable.
Definition at line 62 of file SumEntropyOfCategoricals.h.
PLearn::SumEntropyOfCategoricals::SumEntropyOfCategoricals | ( | ) |
### declare public option fields (such as build options) here Start your comments with Doxygen-compatible comments such as //!
Default constructor, usually does nothing
Definition at line 55 of file SumEntropyOfCategoricals.cc.
: inherited(0, 1, 1) { }
PLearn::SumEntropyOfCategoricals::SumEntropyOfCategoricals | ( | Variable * | input | ) |
string PLearn::SumEntropyOfCategoricals::_classname_ | ( | ) | [static] |
Reimplemented from PLearn::UnaryVariable.
Definition at line 53 of file SumEntropyOfCategoricals.cc.
OptionList & PLearn::SumEntropyOfCategoricals::_getOptionList_ | ( | ) | [static] |
Reimplemented from PLearn::UnaryVariable.
Definition at line 53 of file SumEntropyOfCategoricals.cc.
RemoteMethodMap & PLearn::SumEntropyOfCategoricals::_getRemoteMethodMap_ | ( | ) | [static] |
Reimplemented from PLearn::UnaryVariable.
Definition at line 53 of file SumEntropyOfCategoricals.cc.
Reimplemented from PLearn::UnaryVariable.
Definition at line 53 of file SumEntropyOfCategoricals.cc.
Object * PLearn::SumEntropyOfCategoricals::_new_instance_for_typemap_ | ( | ) | [static] |
Reimplemented from PLearn::UnaryVariable.
Definition at line 53 of file SumEntropyOfCategoricals.cc.
StaticInitializer SumEntropyOfCategoricals::_static_initializer_ & PLearn::SumEntropyOfCategoricals::_static_initialize_ | ( | ) | [static] |
Reimplemented from PLearn::UnaryVariable.
Definition at line 53 of file SumEntropyOfCategoricals.cc.
void PLearn::SumEntropyOfCategoricals::bprop | ( | ) | [virtual] |
Nothing to do by default.
Reimplemented from PLearn::UnaryVariable.
Definition at line 105 of file SumEntropyOfCategoricals.cc.
References PLearn::Variable::gradientdata, i, PLearn::UnaryVariable::input, j, PLearn::TMat< T >::length(), PLearn::P(), pl_log, w, and PLearn::TMat< T >::width().
{ /* [-p log(p)]' = -[log(p) + 1] */ real gr = gradientdata[0]; Mat P = input->matValue; Mat Pgr = input->matGradient; int l = P.length(); int w = P.width(); for(int i=0; i<l; i++) { const real* P_i = P[i]; real* Pgr_i = Pgr[i]; for(int j=0; j<w; j++) { real P_ij = P_i[j]; real logPij = P_ij>1e-25 ?pl_log(P_ij): -57.5; Pgr_i[j] -= gr*(logPij + 1); } } }
void PLearn::SumEntropyOfCategoricals::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 137 of file SumEntropyOfCategoricals.cc.
References PLearn::UnaryVariable::build(), and build_().
{ inherited::build(); build_(); }
void PLearn::SumEntropyOfCategoricals::build_ | ( | ) | [private] |
This does the actual building.
Reimplemented from PLearn::UnaryVariable.
Definition at line 168 of file SumEntropyOfCategoricals.cc.
Referenced by build(), and SumEntropyOfCategoricals().
{ // ### This method should do the real building of the object, // ### according to set 'options', in *any* situation. // ### Typical situations include: // ### - Initial building of an object from a few user-specified options // ### - Building of a "reloaded" object: i.e. from the complete set of // ### all serialised options. // ### - Updating or "re-building" of an object after a few "tuning" // ### options have been modified. // ### You should assume that the parent class' build_() has already been // ### called. }
string PLearn::SumEntropyOfCategoricals::classname | ( | ) | const [virtual] |
Reimplemented from PLearn::UnaryVariable.
Definition at line 53 of file SumEntropyOfCategoricals.cc.
void PLearn::SumEntropyOfCategoricals::declareOptions | ( | OptionList & | ol | ) | [static, protected] |
Declares the class options.
Reimplemented from PLearn::UnaryVariable.
Definition at line 148 of file SumEntropyOfCategoricals.cc.
References PLearn::UnaryVariable::declareOptions().
{ // ### Declare all of this object's options here. // ### For the "flags" of each option, you should typically specify // ### one of OptionBase::buildoption, OptionBase::learntoption or // ### OptionBase::tuningoption. If you don't provide one of these three, // ### this option will be ignored when loading values from a script. // ### You can also combine flags, for example with OptionBase::nosave: // ### (OptionBase::buildoption | OptionBase::nosave) // ### ex: // declareOption(ol, "myoption", &SumEntropyOfCategoricals::myoption, // OptionBase::buildoption, // "Help text describing this option"); // ... // Now call the parent class' declareOptions inherited::declareOptions(ol); }
static const PPath& PLearn::SumEntropyOfCategoricals::declaringFile | ( | ) | [inline, static] |
Reimplemented from PLearn::UnaryVariable.
Definition at line 103 of file SumEntropyOfCategoricals.h.
:
//##### Protected Options ###############################################
SumEntropyOfCategoricals * PLearn::SumEntropyOfCategoricals::deepCopy | ( | CopiesMap & | copies | ) | const [virtual] |
Reimplemented from PLearn::UnaryVariable.
Definition at line 53 of file SumEntropyOfCategoricals.cc.
void PLearn::SumEntropyOfCategoricals::fprop | ( | ) | [virtual] |
Nothing to do by default.
Reimplemented from PLearn::UnaryVariable.
Definition at line 84 of file SumEntropyOfCategoricals.cc.
References i, PLearn::UnaryVariable::input, j, PLearn::TMat< T >::length(), PLearn::P(), pl_log, PLearn::Variable::valuedata, w, and PLearn::TMat< T >::width().
{ double res = 0; Mat P = input->matValue; int l = P.length(); int w = P.width(); for(int i=0; i<l; i++) { const real* P_i = P[i]; for(int j=0; j<w; j++) { real P_ij = P_i[j]; if( P_ij>1e-25 ) res += P_ij*pl_log(P_ij); } } valuedata[0] = -(real)res; }
OptionList & PLearn::SumEntropyOfCategoricals::getOptionList | ( | ) | const [virtual] |
Reimplemented from PLearn::UnaryVariable.
Definition at line 53 of file SumEntropyOfCategoricals.cc.
OptionMap & PLearn::SumEntropyOfCategoricals::getOptionMap | ( | ) | const [virtual] |
Reimplemented from PLearn::UnaryVariable.
Definition at line 53 of file SumEntropyOfCategoricals.cc.
RemoteMethodMap & PLearn::SumEntropyOfCategoricals::getRemoteMethodMap | ( | ) | const [virtual] |
Reimplemented from PLearn::UnaryVariable.
Definition at line 53 of file SumEntropyOfCategoricals.cc.
void PLearn::SumEntropyOfCategoricals::makeDeepCopyFromShallowCopy | ( | CopiesMap & | copies | ) | [virtual] |
Transforms a shallow copy into a deep copy.
Reimplemented from PLearn::UnaryVariable.
Definition at line 143 of file SumEntropyOfCategoricals.cc.
References PLearn::UnaryVariable::makeDeepCopyFromShallowCopy().
{ inherited::makeDeepCopyFromShallowCopy(copies); }
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 78 of file SumEntropyOfCategoricals.cc.
{ l = w = 1; }
Reimplemented from PLearn::UnaryVariable.
Definition at line 103 of file SumEntropyOfCategoricals.h.