PLearn 0.1
|
The first sentence should be a BRIEF DESCRIPTION of what the class does. More...
#include <ArgmaxModule.h>
Public Member Functions | |
ArgmaxModule () | |
### declare public option fields (such as build options) here Start your comments with Doxygen-compatible comments such as //! | |
void | fprop (const TVec< Mat * > &ports_value) |
Perform a fprop step. | |
virtual void | bpropAccUpdate (const TVec< Mat * > &ports_value, const TVec< Mat * > &ports_gradient) |
Perform a back propagation step (also updating parameters according to the provided gradient). | |
virtual void | forget () |
Reset the parameters to the state they would be BEFORE starting training. | |
virtual const TVec< string > & | getPorts () |
Return the list of ports in the module. | |
virtual string | classname () const |
virtual OptionList & | getOptionList () const |
virtual OptionMap & | getOptionMap () const |
virtual RemoteMethodMap & | getRemoteMethodMap () const |
virtual ArgmaxModule * | 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_ () |
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 OnlineLearningModule | inherited |
Private Member Functions | |
void | build_ () |
This does the actual building. |
The first sentence should be a BRIEF DESCRIPTION of what the class does.
Place the rest of the class programmer documentation here. Doxygen supports Javadoc-style comments. See http://www.doxygen.org/manual.html
Definition at line 57 of file ArgmaxModule.h.
typedef OnlineLearningModule PLearn::ArgmaxModule::inherited [private] |
Reimplemented from PLearn::OnlineLearningModule.
Definition at line 59 of file ArgmaxModule.h.
PLearn::ArgmaxModule::ArgmaxModule | ( | ) |
### declare public option fields (such as build options) here Start your comments with Doxygen-compatible comments such as //!
Default constructor
Definition at line 54 of file ArgmaxModule.cc.
{ output_size = 1; }
string PLearn::ArgmaxModule::_classname_ | ( | ) | [static] |
Reimplemented from PLearn::OnlineLearningModule.
Definition at line 52 of file ArgmaxModule.cc.
OptionList & PLearn::ArgmaxModule::_getOptionList_ | ( | ) | [static] |
Reimplemented from PLearn::OnlineLearningModule.
Definition at line 52 of file ArgmaxModule.cc.
RemoteMethodMap & PLearn::ArgmaxModule::_getRemoteMethodMap_ | ( | ) | [static] |
Reimplemented from PLearn::OnlineLearningModule.
Definition at line 52 of file ArgmaxModule.cc.
Reimplemented from PLearn::OnlineLearningModule.
Definition at line 52 of file ArgmaxModule.cc.
Object * PLearn::ArgmaxModule::_new_instance_for_typemap_ | ( | ) | [static] |
Reimplemented from PLearn::Object.
Definition at line 52 of file ArgmaxModule.cc.
StaticInitializer ArgmaxModule::_static_initializer_ & PLearn::ArgmaxModule::_static_initialize_ | ( | ) | [static] |
Reimplemented from PLearn::OnlineLearningModule.
Definition at line 52 of file ArgmaxModule.cc.
void PLearn::ArgmaxModule::bpropAccUpdate | ( | const TVec< Mat * > & | ports_value, |
const TVec< Mat * > & | ports_gradient | ||
) | [virtual] |
Perform a back propagation step (also updating parameters according to the provided gradient).
The matrices in 'ports_value' must be the same as the ones given in a previous call to 'fprop' (and thus they should in particular contain the result of the fprop computation). However, they are not necessarily the same as the ones given in the LAST call to 'fprop': if there is a need to store an internal module state, this should be done using a specific port to store this state. Each Mat* pointer in the 'ports_gradient' vector can be one of:
Reimplemented from PLearn::OnlineLearningModule.
Definition at line 136 of file ArgmaxModule.cc.
References PLearn::TVec< T >::length(), and PLASSERT.
{ PLASSERT( ports_value.length() == nPorts() && ports_gradient.length() == nPorts()); // Currently not implemented. Thus the check below should crash if we // actually ask to compute a gradient. // Ensure all required gradients have been computed. checkProp(ports_gradient); }
void PLearn::ArgmaxModule::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::OnlineLearningModule.
Definition at line 94 of file ArgmaxModule.cc.
{ inherited::build(); build_(); }
void PLearn::ArgmaxModule::build_ | ( | ) | [private] |
This does the actual building.
Reimplemented from PLearn::OnlineLearningModule.
Definition at line 79 of file ArgmaxModule.cc.
{ // ### 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::ArgmaxModule::classname | ( | ) | const [virtual] |
Reimplemented from PLearn::Object.
Definition at line 52 of file ArgmaxModule.cc.
void PLearn::ArgmaxModule::declareOptions | ( | OptionList & | ol | ) | [static, protected] |
Declares the class options.
Reimplemented from PLearn::OnlineLearningModule.
Definition at line 59 of file ArgmaxModule.cc.
{ // ### 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", &ArgmaxModule::myoption, // OptionBase::buildoption, // "Help text describing this option"); // ... // Now call the parent class' declareOptions inherited::declareOptions(ol); }
static const PPath& PLearn::ArgmaxModule::declaringFile | ( | ) | [inline, static] |
Reimplemented from PLearn::OnlineLearningModule.
Definition at line 235 of file ArgmaxModule.h.
:
//##### Protected Member Functions ######################################
ArgmaxModule * PLearn::ArgmaxModule::deepCopy | ( | CopiesMap & | copies | ) | const [virtual] |
Reimplemented from PLearn::OnlineLearningModule.
Definition at line 52 of file ArgmaxModule.cc.
void PLearn::ArgmaxModule::forget | ( | ) | [virtual] |
Reset the parameters to the state they would be BEFORE starting training.
Note that this method is necessarily called from build().
Implements PLearn::OnlineLearningModule.
Definition at line 151 of file ArgmaxModule.cc.
{
// Nothing to forget.
}
Perform a fprop step.
Each Mat* pointer in the 'ports_value' vector can be one of:
Reimplemented from PLearn::OnlineLearningModule.
Definition at line 118 of file ArgmaxModule.cc.
References PLearn::argmax(), i, PLearn::TMat< T >::isEmpty(), PLearn::TVec< T >::length(), PLASSERT, PLCHECK, and PLearn::TMat< T >::resize().
{ PLASSERT( ports_value.length() == nPorts() ); Mat* input = ports_value[0]; Mat* output = ports_value[1]; PLCHECK( input && output && !input->isEmpty() && output->isEmpty() ); output->resize(input->length(), 1); for (int i = 0; i < input->length(); i++) (*output)(i, 0) = argmax((*input)(i)); // Ensure all required ports have been computed. checkProp(ports_value); }
OptionList & PLearn::ArgmaxModule::getOptionList | ( | ) | const [virtual] |
Reimplemented from PLearn::Object.
Definition at line 52 of file ArgmaxModule.cc.
OptionMap & PLearn::ArgmaxModule::getOptionMap | ( | ) | const [virtual] |
Reimplemented from PLearn::Object.
Definition at line 52 of file ArgmaxModule.cc.
const TVec< string > & PLearn::ArgmaxModule::getPorts | ( | ) | [virtual] |
Return the list of ports in the module.
The default implementation returns a pair ("input", "output") to handle the most common case.
Reimplemented from PLearn::OnlineLearningModule.
Definition at line 159 of file ArgmaxModule.cc.
{ return inherited::getPorts(); }
RemoteMethodMap & PLearn::ArgmaxModule::getRemoteMethodMap | ( | ) | const [virtual] |
Reimplemented from PLearn::Object.
Definition at line 52 of file ArgmaxModule.cc.
void PLearn::ArgmaxModule::makeDeepCopyFromShallowCopy | ( | CopiesMap & | copies | ) | [virtual] |
Transforms a shallow copy into a deep copy.
Reimplemented from PLearn::OnlineLearningModule.
Definition at line 101 of file ArgmaxModule.cc.
References PLERROR.
{ inherited::makeDeepCopyFromShallowCopy(copies); // ### Call deepCopyField on all "pointer-like" fields // ### that you wish to be deepCopied rather than // ### shallow-copied. // ### ex: // deepCopyField(trainvec, copies); // ### Remove this line when you have fully implemented this method. PLERROR("ArgmaxModule::makeDeepCopyFromShallowCopy not fully (correctly) implemented yet!"); }
Reimplemented from PLearn::OnlineLearningModule.
Definition at line 235 of file ArgmaxModule.h.