PLearn 0.1
|
#include <LearnerProcessedVMatrix.h>
Public Member Functions | |
LearnerProcessedVMatrix () | |
virtual void | build () |
Simply calls inherited::build() then build_(). | |
virtual void | makeDeepCopyFromShallowCopy (CopiesMap &copies) |
Transforms a shallow copy into a deep copy. | |
virtual string | classname () const |
virtual OptionList & | getOptionList () const |
virtual OptionMap & | getOptionMap () const |
virtual RemoteMethodMap & | getRemoteMethodMap () const |
virtual LearnerProcessedVMatrix * | deepCopy (CopiesMap &copies) const |
Static Public Member Functions | |
static string | _classname_ () |
Declares name and deepCopy methods. | |
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 | |
VMat | source |
The source vmatrix whose inputs wil be porcessed by the learner If present, the target and weight columns will be appended to the processed input in the resulting matrix. | |
PP< PLearner > | learner |
The learner used to process the VMat's input. | |
char | train_learner |
Indicates if the learner should be trained on the source, and on what part '0': don't train 'S': supervised training using input and target (possibly weighted if weight is present) 'U': unsupervised training using only input part (possibly weighted if weight is present). | |
Static Public Attributes | |
static StaticInitializer | _static_initializer_ |
Protected Member Functions | |
virtual void | getNewRow (int i, const Vec &v) const |
This is the only method requiring implementation. | |
Static Protected Member Functions | |
static void | declareOptions (OptionList &ol) |
Declares this class' options. | |
Private Types | |
typedef RowBufferedVMatrix | inherited |
Private Member Functions | |
void | build_ () |
This does the actual building. |
Definition at line 50 of file LearnerProcessedVMatrix.h.
typedef RowBufferedVMatrix PLearn::LearnerProcessedVMatrix::inherited [private] |
Reimplemented from PLearn::RowBufferedVMatrix.
Definition at line 52 of file LearnerProcessedVMatrix.h.
PLearn::LearnerProcessedVMatrix::LearnerProcessedVMatrix | ( | ) |
Definition at line 51 of file LearnerProcessedVMatrix.cc.
References build_().
:train_learner('-') { build_(); }
string PLearn::LearnerProcessedVMatrix::_classname_ | ( | ) | [static] |
Declares name and deepCopy methods.
Reimplemented from PLearn::RowBufferedVMatrix.
Definition at line 48 of file LearnerProcessedVMatrix.cc.
OptionList & PLearn::LearnerProcessedVMatrix::_getOptionList_ | ( | ) | [static] |
Reimplemented from PLearn::RowBufferedVMatrix.
Definition at line 48 of file LearnerProcessedVMatrix.cc.
RemoteMethodMap & PLearn::LearnerProcessedVMatrix::_getRemoteMethodMap_ | ( | ) | [static] |
Reimplemented from PLearn::RowBufferedVMatrix.
Definition at line 48 of file LearnerProcessedVMatrix.cc.
Reimplemented from PLearn::RowBufferedVMatrix.
Definition at line 48 of file LearnerProcessedVMatrix.cc.
Object * PLearn::LearnerProcessedVMatrix::_new_instance_for_typemap_ | ( | ) | [static] |
Reimplemented from PLearn::Object.
Definition at line 48 of file LearnerProcessedVMatrix.cc.
StaticInitializer LearnerProcessedVMatrix::_static_initializer_ & PLearn::LearnerProcessedVMatrix::_static_initialize_ | ( | ) | [static] |
Reimplemented from PLearn::RowBufferedVMatrix.
Definition at line 48 of file LearnerProcessedVMatrix.cc.
void PLearn::LearnerProcessedVMatrix::build | ( | ) | [virtual] |
Simply calls inherited::build() then build_().
Reimplemented from PLearn::VMatrix.
Definition at line 115 of file LearnerProcessedVMatrix.cc.
References PLearn::VMatrix::build(), and build_().
{ inherited::build(); build_(); }
void PLearn::LearnerProcessedVMatrix::build_ | ( | ) | [private] |
This does the actual building.
Reimplemented from PLearn::VMatrix.
Definition at line 90 of file LearnerProcessedVMatrix.cc.
References learner, PLearn::VMat::length(), PLearn::VMatrix::length_, source, PLearn::VMat::subMatColumns(), train_learner, and PLearn::VMatrix::width_.
Referenced by build(), and LearnerProcessedVMatrix().
{ if (source && learner) { switch(train_learner) { case '-': break; case 'S': learner->setTrainingSet(source); learner->setTrainStatsCollector(new VecStatsCollector()); learner->train(); break; case 'U': { VMat inputs = source.subMatColumns(0,source->inputsize()); learner->setTrainingSet(inputs); learner->setTrainStatsCollector(new VecStatsCollector()); learner->train(); } } length_ = source->length(); width_ = learner->outputsize() + source->targetsize() + source->weightsize(); } }
string PLearn::LearnerProcessedVMatrix::classname | ( | ) | const [virtual] |
Reimplemented from PLearn::Object.
Definition at line 48 of file LearnerProcessedVMatrix.cc.
void PLearn::LearnerProcessedVMatrix::declareOptions | ( | OptionList & | ol | ) | [static, protected] |
Declares this class' options.
Reimplemented from PLearn::VMatrix.
Definition at line 71 of file LearnerProcessedVMatrix.cc.
References PLearn::OptionBase::buildoption, PLearn::declareOption(), PLearn::VMatrix::declareOptions(), learner, source, and train_learner.
{ declareOption(ol, "source", &LearnerProcessedVMatrix::source, OptionBase::buildoption, "The source vmatrix whose inputs wil be porcessed by the learner.\n" "If present, the target and weight columns will be appended to the processed input in the resulting matrix."); declareOption(ol, "learner", &LearnerProcessedVMatrix::learner, OptionBase::buildoption, "The learner used to process the VMat's input."); declareOption(ol, "train_learner", &LearnerProcessedVMatrix::train_learner, OptionBase::buildoption, "Indicates if the learner should be trained on the source, upon building, and if so on what part.\n" " '-': don't train \n" " 'S': supervised training using input and target (possibly weighted if weight is present) \n" " 'U': unsupervised training using only input part (possibly weighted if weight is present). \n"); // Now call the parent class' declareOptions inherited::declareOptions(ol); }
static const PPath& PLearn::LearnerProcessedVMatrix::declaringFile | ( | ) | [inline, static] |
Reimplemented from PLearn::RowBufferedVMatrix.
Definition at line 111 of file LearnerProcessedVMatrix.h.
LearnerProcessedVMatrix * PLearn::LearnerProcessedVMatrix::deepCopy | ( | CopiesMap & | copies | ) | const [virtual] |
Reimplemented from PLearn::RowBufferedVMatrix.
Definition at line 48 of file LearnerProcessedVMatrix.cc.
This is the only method requiring implementation.
Implements PLearn::RowBufferedVMatrix.
Definition at line 57 of file LearnerProcessedVMatrix.cc.
References learner, PLearn::TVec< T >::resize(), source, PLearn::TVec< T >::subVec(), and PLearn::VMat::width().
{ static Vec sv; sv.resize(source.width()); source->getRow(i,sv); int nin = source->inputsize(); int nout = learner->outputsize(); Vec input = sv.subVec(0,nin); Vec output = v.subVec(0,nout); learner->computeOutput(input,output); int rest = source.width()-nin; v.subVec(nout,rest) << sv.subVec(nin,rest); }
OptionList & PLearn::LearnerProcessedVMatrix::getOptionList | ( | ) | const [virtual] |
Reimplemented from PLearn::Object.
Definition at line 48 of file LearnerProcessedVMatrix.cc.
OptionMap & PLearn::LearnerProcessedVMatrix::getOptionMap | ( | ) | const [virtual] |
Reimplemented from PLearn::Object.
Definition at line 48 of file LearnerProcessedVMatrix.cc.
RemoteMethodMap & PLearn::LearnerProcessedVMatrix::getRemoteMethodMap | ( | ) | const [virtual] |
Reimplemented from PLearn::Object.
Definition at line 48 of file LearnerProcessedVMatrix.cc.
void PLearn::LearnerProcessedVMatrix::makeDeepCopyFromShallowCopy | ( | CopiesMap & | copies | ) | [virtual] |
Transforms a shallow copy into a deep copy.
Reimplemented from PLearn::RowBufferedVMatrix.
Definition at line 121 of file LearnerProcessedVMatrix.cc.
References PLearn::deepCopyField(), learner, PLearn::RowBufferedVMatrix::makeDeepCopyFromShallowCopy(), and source.
{ inherited::makeDeepCopyFromShallowCopy(copies); deepCopyField(source, copies); deepCopyField(learner, copies); }
Reimplemented from PLearn::RowBufferedVMatrix.
Definition at line 111 of file LearnerProcessedVMatrix.h.
The learner used to process the VMat's input.
Definition at line 70 of file LearnerProcessedVMatrix.h.
Referenced by build_(), declareOptions(), getNewRow(), and makeDeepCopyFromShallowCopy().
The source vmatrix whose inputs wil be porcessed by the learner If present, the target and weight columns will be appended to the processed input in the resulting matrix.
Definition at line 67 of file LearnerProcessedVMatrix.h.
Referenced by build_(), declareOptions(), getNewRow(), and makeDeepCopyFromShallowCopy().
Indicates if the learner should be trained on the source, and on what part '0': don't train 'S': supervised training using input and target (possibly weighted if weight is present) 'U': unsupervised training using only input part (possibly weighted if weight is present).
Definition at line 76 of file LearnerProcessedVMatrix.h.
Referenced by build_(), and declareOptions().