PLearn 0.1
|
#include <SourceVMatrixSplitter.h>
Public Member Functions | |
SourceVMatrixSplitter () | |
virtual void | build () |
Post-constructor. | |
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 SourceVMatrixSplitter * | deepCopy (CopiesMap &copies) const |
virtual void | setDataSet (VMat the_dataset) |
Overridden to forward to underlying splitter. | |
virtual int | nsplits () const |
Returns the number of available different "splits". | |
virtual int | nSetsPerSplit () const |
Returns the number of sets per split. | |
virtual TVec< VMat > | getSplit (int i=0) |
Returns split number i. | |
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 | |
PP< SourceVMatrix > | source_vm |
PP< Splitter > | source_splitter |
int | to_apply |
TVec< int > | sets_to_modify |
Static Public Attributes | |
static StaticInitializer | _static_initializer_ |
Static Protected Member Functions | |
static void | declareOptions (OptionList &ol) |
Declares this class' options. | |
Private Types | |
typedef Splitter | inherited |
Private Member Functions | |
void | build_ () |
This does the actual building. |
Definition at line 53 of file SourceVMatrixSplitter.h.
typedef Splitter PLearn::SourceVMatrixSplitter::inherited [private] |
Reimplemented from PLearn::Splitter.
Definition at line 58 of file SourceVMatrixSplitter.h.
PLearn::SourceVMatrixSplitter::SourceVMatrixSplitter | ( | ) |
Definition at line 52 of file SourceVMatrixSplitter.cc.
: to_apply(0) { }
string PLearn::SourceVMatrixSplitter::_classname_ | ( | ) | [static] |
Declares name and deepCopy methods.
Reimplemented from PLearn::Splitter.
Definition at line 63 of file SourceVMatrixSplitter.cc.
OptionList & PLearn::SourceVMatrixSplitter::_getOptionList_ | ( | ) | [static] |
Reimplemented from PLearn::Splitter.
Definition at line 63 of file SourceVMatrixSplitter.cc.
RemoteMethodMap & PLearn::SourceVMatrixSplitter::_getRemoteMethodMap_ | ( | ) | [static] |
Reimplemented from PLearn::Splitter.
Definition at line 63 of file SourceVMatrixSplitter.cc.
Reimplemented from PLearn::Splitter.
Definition at line 63 of file SourceVMatrixSplitter.cc.
Object * PLearn::SourceVMatrixSplitter::_new_instance_for_typemap_ | ( | ) | [static] |
Reimplemented from PLearn::Object.
Definition at line 63 of file SourceVMatrixSplitter.cc.
StaticInitializer SourceVMatrixSplitter::_static_initializer_ & PLearn::SourceVMatrixSplitter::_static_initialize_ | ( | ) | [static] |
Reimplemented from PLearn::Splitter.
Definition at line 63 of file SourceVMatrixSplitter.cc.
void PLearn::SourceVMatrixSplitter::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::Object.
Definition at line 101 of file SourceVMatrixSplitter.cc.
References PLearn::Object::build(), and build_().
{ inherited::build(); build_(); }
void PLearn::SourceVMatrixSplitter::build_ | ( | ) | [private] |
This does the actual building.
Reimplemented from PLearn::Object.
Definition at line 90 of file SourceVMatrixSplitter.cc.
References PLDEPRECATED, and to_apply.
Referenced by build().
{ if (to_apply != 0) // This deprecated option is being used. PLDEPRECATED("In SourceVMatrixSplitter::build_ - Use 'sets_to_modify' instead of the deprecated " "'to_apply' option."); }
string PLearn::SourceVMatrixSplitter::classname | ( | ) | const [virtual] |
Reimplemented from PLearn::Object.
Definition at line 63 of file SourceVMatrixSplitter.cc.
void PLearn::SourceVMatrixSplitter::declareOptions | ( | OptionList & | ol | ) | [static, protected] |
Declares this class' options.
Reimplemented from PLearn::Splitter.
Definition at line 68 of file SourceVMatrixSplitter.cc.
References PLearn::OptionBase::buildoption, PLearn::declareOption(), PLearn::Splitter::declareOptions(), sets_to_modify, source_splitter, source_vm, and to_apply.
{ declareOption(ol, "source_vm", &SourceVMatrixSplitter::source_vm, OptionBase::buildoption, "The VMatrix to apply."); declareOption(ol, "source_splitter", &SourceVMatrixSplitter::source_splitter, OptionBase::buildoption, "The underlying splitter."); declareOption(ol, "to_apply", &SourceVMatrixSplitter::to_apply, OptionBase::buildoption, "Deprecated: the index of the returned set where we apply source_vm."); declareOption(ol, "sets_to_modify", &SourceVMatrixSplitter::sets_to_modify, OptionBase::buildoption, "The indices of the returned sets on which we apply source_vm ([-1] means all sets).\n" "This option will override 'to_apply' if it is also provided."); // Now call the parent class' declareOptions inherited::declareOptions(ol); }
static const PPath& PLearn::SourceVMatrixSplitter::declaringFile | ( | ) | [inline, static] |
Reimplemented from PLearn::Splitter.
Definition at line 110 of file SourceVMatrixSplitter.h.
SourceVMatrixSplitter * PLearn::SourceVMatrixSplitter::deepCopy | ( | CopiesMap & | copies | ) | const [virtual] |
Reimplemented from PLearn::Splitter.
Definition at line 63 of file SourceVMatrixSplitter.cc.
Referenced by getSplit().
OptionList & PLearn::SourceVMatrixSplitter::getOptionList | ( | ) | const [virtual] |
Reimplemented from PLearn::Object.
Definition at line 63 of file SourceVMatrixSplitter.cc.
OptionMap & PLearn::SourceVMatrixSplitter::getOptionMap | ( | ) | const [virtual] |
Reimplemented from PLearn::Object.
Definition at line 63 of file SourceVMatrixSplitter.cc.
RemoteMethodMap & PLearn::SourceVMatrixSplitter::getRemoteMethodMap | ( | ) | const [virtual] |
Reimplemented from PLearn::Object.
Definition at line 63 of file SourceVMatrixSplitter.cc.
Returns split number i.
Implements PLearn::Splitter.
Definition at line 143 of file SourceVMatrixSplitter.cc.
References deepCopy(), i, PLearn::TVec< T >::isEmpty(), PLearn::TVec< T >::length(), PLDEPRECATED, sets_to_modify, source_splitter, source_vm, and to_apply.
{ TVec<VMat> result = source_splitter->getSplit(k); if (sets_to_modify.isEmpty()) { // Old code, to remove when the deprecated option 'to_apply' is removed. PLDEPRECATED("In SourceVMatrixSplitter::getSplit - Use 'sets_to_modify' instead of the deprecated " "'to_apply' option."); source_vm->source = result[to_apply]; source_vm->build(); VMat the_vm = static_cast<SourceVMatrix*>(source_vm); result[to_apply] = the_vm; } else { TVec<int> sets_indices = sets_to_modify; if (sets_indices.length() == 1 && sets_indices[0] == -1) { // -1 means we apply it on all sets. sets_indices = TVec<int>(0, source_splitter->nSetsPerSplit() - 1, 1); } for (int i = 0; i < sets_indices.length(); i++) { int set = sets_indices[i]; // Clear the source of 'source_vm' since we do not want to deep-copy it. source_vm->source = 0; // Copy 'source_vm' and fill 'result' accordingly. PP<SourceVMatrix> vm_copy = PLearn::deepCopy(source_vm); vm_copy->source = result[set]; vm_copy->build(); result[set] = (SourceVMatrix*) vm_copy; } } return result; }
void PLearn::SourceVMatrixSplitter::makeDeepCopyFromShallowCopy | ( | CopiesMap & | copies | ) | [virtual] |
Transforms a shallow copy into a deep copy.
Reimplemented from PLearn::Splitter.
Definition at line 110 of file SourceVMatrixSplitter.cc.
References PLearn::Splitter::makeDeepCopyFromShallowCopy(), and 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("SourceVMatrixSplitter::makeDeepCopyFromShallowCopy not fully (correctly) implemented yet!"); }
int PLearn::SourceVMatrixSplitter::nSetsPerSplit | ( | ) | const [virtual] |
Returns the number of sets per split.
Implements PLearn::Splitter.
Definition at line 135 of file SourceVMatrixSplitter.cc.
References source_splitter.
{ return source_splitter->nSetsPerSplit(); }
int PLearn::SourceVMatrixSplitter::nsplits | ( | ) | const [virtual] |
Returns the number of available different "splits".
Implements PLearn::Splitter.
Definition at line 127 of file SourceVMatrixSplitter.cc.
References source_splitter.
{ return source_splitter->nsplits(); }
void PLearn::SourceVMatrixSplitter::setDataSet | ( | VMat | the_dataset | ) | [virtual] |
Overridden to forward to underlying splitter.
Reimplemented from PLearn::Splitter.
Definition at line 177 of file SourceVMatrixSplitter.cc.
References PLearn::Splitter::setDataSet(), and source_splitter.
{ inherited::setDataSet(the_dataset); source_splitter->setDataSet(the_dataset); }
Reimplemented from PLearn::Splitter.
Definition at line 110 of file SourceVMatrixSplitter.h.
Definition at line 77 of file SourceVMatrixSplitter.h.
Referenced by declareOptions(), and getSplit().
Definition at line 75 of file SourceVMatrixSplitter.h.
Referenced by declareOptions(), getSplit(), nSetsPerSplit(), nsplits(), and setDataSet().
Definition at line 74 of file SourceVMatrixSplitter.h.
Referenced by declareOptions(), and getSplit().
Definition at line 76 of file SourceVMatrixSplitter.h.
Referenced by build_(), declareOptions(), and getSplit().