|
PLearn 0.1
|
Identity Learner with a cached 'processDataSet' method. More...
#include <PrecomputedProcessedLearner.h>


Public Member Functions | |
| PrecomputedProcessedLearner () | |
| Default constructor. | |
| virtual int | outputsize () const |
| Return the inputsize from the last setTrainingSet. | |
| virtual void | forget () |
| No-op in this learner. | |
| virtual void | train () |
| No-op in this learner. | |
| virtual void | computeOutput (const Vec &input, Vec &output) const |
| Computes the output from the input: identity function. | |
| virtual void | computeCostsFromOutputs (const Vec &input, const Vec &output, const Vec &target, Vec &costs) const |
| No-op in this learner. | |
| virtual TVec< std::string > | getTestCostNames () const |
| This learner does not have any test costs. | |
| virtual TVec< std::string > | getTrainCostNames () const |
| This learner does not have any train costs. | |
| virtual VMat | processDataSet (VMat dataset) const |
| Process a full dataset (possibly containing input,target,weight,extra parts). | |
| virtual string | classname () const |
| virtual OptionList & | getOptionList () const |
| virtual OptionMap & | getOptionMap () const |
| virtual RemoteMethodMap & | getRemoteMethodMap () const |
| virtual PrecomputedProcessedLearner * | deepCopy (CopiesMap &copies) const |
| virtual void | build () |
| Finish building the object; just call inherited::build followed by build_() | |
| 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 () |
Public Attributes | |
| string | m_precomp_type |
| Buffering type for precomputed train operations. | |
Static Public Attributes | |
| static StaticInitializer | _static_initializer_ |
Static Protected Member Functions | |
| static void | declareOptions (OptionList &ol) |
| Declares the class options. | |
Private Types | |
| typedef PLearner | inherited |
Private Member Functions | |
| void | build_ () |
| This does the actual building. | |
Identity Learner with a cached 'processDataSet' method.
This learner is functionally the identity learner: it does not learn anything, and its computeOutput() produces the same thing as its input. HOWEVER, it implements a special function: the results of calls to processDataSet produce a CACHED VMatrix of the results, thereby making further accesses much faster.
The intended use of this learner is within a chain managed by a ChainedLearner, wherein one has the pattern
Definition at line 63 of file PrecomputedProcessedLearner.h.
typedef PLearner PLearn::PrecomputedProcessedLearner::inherited [private] |
Reimplemented from PLearn::PLearner.
Definition at line 65 of file PrecomputedProcessedLearner.h.
| PLearn::PrecomputedProcessedLearner::PrecomputedProcessedLearner | ( | ) |
Default constructor.
Definition at line 68 of file PrecomputedProcessedLearner.cc.
: m_precomp_type("memory") { }
| string PLearn::PrecomputedProcessedLearner::_classname_ | ( | ) | [static] |
Reimplemented from PLearn::PLearner.
Definition at line 65 of file PrecomputedProcessedLearner.cc.
| OptionList & PLearn::PrecomputedProcessedLearner::_getOptionList_ | ( | ) | [static] |
Reimplemented from PLearn::PLearner.
Definition at line 65 of file PrecomputedProcessedLearner.cc.
| RemoteMethodMap & PLearn::PrecomputedProcessedLearner::_getRemoteMethodMap_ | ( | ) | [static] |
Reimplemented from PLearn::PLearner.
Definition at line 65 of file PrecomputedProcessedLearner.cc.
Reimplemented from PLearn::PLearner.
Definition at line 65 of file PrecomputedProcessedLearner.cc.
| Object * PLearn::PrecomputedProcessedLearner::_new_instance_for_typemap_ | ( | ) | [static] |
Reimplemented from PLearn::Object.
Definition at line 65 of file PrecomputedProcessedLearner.cc.
| StaticInitializer PrecomputedProcessedLearner::_static_initializer_ & PLearn::PrecomputedProcessedLearner::_static_initialize_ | ( | ) | [static] |
Reimplemented from PLearn::PLearner.
Definition at line 65 of file PrecomputedProcessedLearner.cc.
| void PLearn::PrecomputedProcessedLearner::build | ( | ) | [virtual] |
Finish building the object; just call inherited::build followed by build_()
Reimplemented from PLearn::PLearner.
Definition at line 100 of file PrecomputedProcessedLearner.cc.
References PLearn::PLearner::build(), and build_().
{
inherited::build();
build_();
}

| void PLearn::PrecomputedProcessedLearner::build_ | ( | ) | [private] |
This does the actual building.
Reimplemented from PLearn::PLearner.
Definition at line 88 of file PrecomputedProcessedLearner.cc.
References m_precomp_type, and PLERROR.
Referenced by build().
{
if (m_precomp_type != "memory" &&
m_precomp_type != "dmat" &&
m_precomp_type != "pmat" )
PLERROR("%s: unknown value for option 'precomp_type' (= '%s');\n"
"must be one of: 'memory', 'dmat', 'pmat'", __FUNCTION__,
m_precomp_type.c_str());
}

| string PLearn::PrecomputedProcessedLearner::classname | ( | ) | const [virtual] |
Reimplemented from PLearn::Object.
Definition at line 65 of file PrecomputedProcessedLearner.cc.
| void PLearn::PrecomputedProcessedLearner::computeCostsFromOutputs | ( | const Vec & | input, |
| const Vec & | output, | ||
| const Vec & | target, | ||
| Vec & | costs | ||
| ) | const [virtual] |
No-op in this learner.
Implements PLearn::PLearner.
Definition at line 135 of file PrecomputedProcessedLearner.cc.
{
// No-op
}
| void PLearn::PrecomputedProcessedLearner::computeOutput | ( | const Vec & | input, |
| Vec & | output | ||
| ) | const [virtual] |
Computes the output from the input: identity function.
Reimplemented from PLearn::PLearner.
Definition at line 129 of file PrecomputedProcessedLearner.cc.
{
output << input;
}
| void PLearn::PrecomputedProcessedLearner::declareOptions | ( | OptionList & | ol | ) | [static, protected] |
Declares the class options.
Reimplemented from PLearn::PLearner.
Definition at line 72 of file PrecomputedProcessedLearner.cc.
References PLearn::OptionBase::buildoption, PLearn::declareOption(), PLearn::PLearner::declareOptions(), and m_precomp_type.
{
declareOption(
ol, "precomp_type", &PrecomputedProcessedLearner::m_precomp_type,
OptionBase::buildoption,
"Buffering type for precomputed train operations. Can be 'memory',\n"
"'dmat', or 'pmat'. In the first case, a MemoryVMatrix is returned from\n"
"calls to ProcessDataSet. In the last two cases, a PrecomputedVMatrix\n"
"is returned, with the appropriate precompute type set. The metadatadir\n"
"of the vmat is set to be the learner's expdir/ followed by\n"
"'precomputed_processed.metadata'.\n");
// Now call the parent class' declareOptions
inherited::declareOptions(ol);
}

| static const PPath& PLearn::PrecomputedProcessedLearner::declaringFile | ( | ) | [inline, static] |
Reimplemented from PLearn::PLearner.
Definition at line 123 of file PrecomputedProcessedLearner.h.
:
| PrecomputedProcessedLearner * PLearn::PrecomputedProcessedLearner::deepCopy | ( | CopiesMap & | copies | ) | const [virtual] |
Reimplemented from PLearn::PLearner.
Definition at line 65 of file PrecomputedProcessedLearner.cc.
| void PLearn::PrecomputedProcessedLearner::forget | ( | ) | [virtual] |
No-op in this learner.
Reimplemented from PLearn::PLearner.
Definition at line 118 of file PrecomputedProcessedLearner.cc.
References PLearn::PLearner::forget().
{
inherited::forget();
}

| OptionList & PLearn::PrecomputedProcessedLearner::getOptionList | ( | ) | const [virtual] |
Reimplemented from PLearn::Object.
Definition at line 65 of file PrecomputedProcessedLearner.cc.
| OptionMap & PLearn::PrecomputedProcessedLearner::getOptionMap | ( | ) | const [virtual] |
Reimplemented from PLearn::Object.
Definition at line 65 of file PrecomputedProcessedLearner.cc.
| RemoteMethodMap & PLearn::PrecomputedProcessedLearner::getRemoteMethodMap | ( | ) | const [virtual] |
Reimplemented from PLearn::Object.
Definition at line 65 of file PrecomputedProcessedLearner.cc.
| TVec< string > PLearn::PrecomputedProcessedLearner::getTestCostNames | ( | ) | const [virtual] |
This learner does not have any test costs.
Implements PLearn::PLearner.
Definition at line 142 of file PrecomputedProcessedLearner.cc.
{
return TVec<string>();
}
| TVec< string > PLearn::PrecomputedProcessedLearner::getTrainCostNames | ( | ) | const [virtual] |
This learner does not have any train costs.
Implements PLearn::PLearner.
Definition at line 148 of file PrecomputedProcessedLearner.cc.
{
return TVec<string>();
}
| void PLearn::PrecomputedProcessedLearner::makeDeepCopyFromShallowCopy | ( | CopiesMap & | copies | ) | [virtual] |
Transforms a shallow copy into a deep copy.
Reimplemented from PLearn::PLearner.
Definition at line 107 of file PrecomputedProcessedLearner.cc.
References PLearn::PLearner::makeDeepCopyFromShallowCopy().
{
inherited::makeDeepCopyFromShallowCopy(copies);
}

| int PLearn::PrecomputedProcessedLearner::outputsize | ( | ) | const [virtual] |
Return the inputsize from the last setTrainingSet.
Implements PLearn::PLearner.
Definition at line 113 of file PrecomputedProcessedLearner.cc.
References PLearn::PLearner::inputsize_.
{
return inputsize_;
}
Process a full dataset (possibly containing input,target,weight,extra parts).
Returns the PRECOMPUTED processed view of that dataset; this is done by passing the result from the inherited processDataSet through the appropriate VMatrix (depending on precomp_type).
Reimplemented from PLearn::PLearner.
Definition at line 154 of file PrecomputedProcessedLearner.cc.
References PLearn::endl(), PLearn::PLearner::expdir, PLearn::PLearner::getExperimentDirectory(), PLearn::getProcessDataMemory(), PLearn::VMat::length(), m_precomp_type, PLERROR, PLearn::PLearner::processDataSet(), PLearn::VMat::toMat(), and PLearn::VMat::width().
{
VMat raw_processed = inherited::processDataSet(dataset);
DBG_MODULE_LOG << "BEFORE PRECOMPUTE. Process memory: "
<< getProcessDataMemory() << endl;
MODULE_LOG << "Precomputing "
<< raw_processed.length() << 'x' << raw_processed.width()
<< " to " << m_precomp_type
<< endl;
if (m_precomp_type == "memory") {
Mat precomp = raw_processed.toMat();
DBG_MODULE_LOG << "AFTER PRECOMPUTE. Process memory: "
<< getProcessDataMemory() << endl;
return VMat(precomp);
}
else {
PPath expdir = getExperimentDirectory();
if (expdir.empty())
PLERROR("%s: an experiment directory must be set in order to use precomp_type '%s'",
__FUNCTION__, m_precomp_type.c_str());
PP<PrecomputedVMatrix> precomp = new PrecomputedVMatrix;
precomp->source = raw_processed;
precomp->precomp_type = m_precomp_type;
precomp->build();
precomp->setMetaDataDir(expdir / "precomputed_processed.metadata");
DBG_MODULE_LOG << "AFTER PRECOMPUTE. Process memory: "
<< getProcessDataMemory() << endl;
return (VMatrix*)precomp;
}
}

| void PLearn::PrecomputedProcessedLearner::train | ( | ) | [virtual] |
No-op in this learner.
Implements PLearn::PLearner.
Definition at line 123 of file PrecomputedProcessedLearner.cc.
{
// No-op
}
Reimplemented from PLearn::PLearner.
Definition at line 123 of file PrecomputedProcessedLearner.h.
Buffering type for precomputed train operations.
Can be 'memory', 'dmat', or 'pmat'. In the first case, a MemoryVMatrix is returned from calls to ProcessDataSet. In the last two cases, a PrecomputedVMatrix is returned, with the appropriate precompute type set. The metadatadir of the vmat is set to be the learner's expdir/ followed by 'precomputed_processed.metadata'.
Definition at line 78 of file PrecomputedProcessedLearner.h.
Referenced by build_(), declareOptions(), and processDataSet().
1.7.4