PLearn 0.1
|
A scalar var; equal 1 if input1!=c, 0 otherwise. More...
#include <IsMissingVariable.h>
Public Member Functions | |
IsMissingVariable () | |
Default constructor for persistence. | |
IsMissingVariable (Variable *input1, bool parallel=0, bool set_parallel_missing_output=0, Vec parallel_missing_outputs=Vec(0)) | |
virtual string | classname () const |
virtual OptionList & | getOptionList () const |
virtual OptionMap & | getOptionMap () const |
virtual RemoteMethodMap & | getRemoteMethodMap () const |
virtual IsMissingVariable * | deepCopy (CopiesMap &copies) const |
virtual void | build () |
Post-constructor. | |
virtual string | info () const |
Returns a bit more informative string about object (default returns classname()) | |
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 void | symbolicBprop () |
compute a piece of new Var graph that represents the symbolic derivative of this Var | |
virtual void | makeDeepCopyFromShallowCopy (CopiesMap &copies) |
Transforms a shallow copy into a deep copy. | |
Static Public Member Functions | |
static string | _classname_ () |
IsMissingVariable. | |
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 void | declareOptions (OptionList &ol) |
Declare options (data fields) for the class. | |
Static Public Attributes | |
static StaticInitializer | _static_initializer_ |
Protected Attributes | |
bool | parallel |
if true then output 1 value per input, otherwise output 1 if ANY of the inputs is missing | |
bool | set_parallel_missing_output |
Indication that, instead of outputing 0 if the input value is NaN, 1 otherwise, this variable will output parallel_missing_output if the input value is NaN, or the actual input value otherwise. | |
Vec | parallel_missing_outputs |
Output value when input is missing (NaN) | |
Private Types | |
typedef UnaryVariable | inherited |
Private Member Functions | |
void | build_ () |
This does the actual building. |
A scalar var; equal 1 if input1!=c, 0 otherwise.
Definition at line 53 of file IsMissingVariable.h.
typedef UnaryVariable PLearn::IsMissingVariable::inherited [private] |
Reimplemented from PLearn::UnaryVariable.
Definition at line 55 of file IsMissingVariable.h.
PLearn::IsMissingVariable::IsMissingVariable | ( | ) | [inline] |
PLearn::IsMissingVariable::IsMissingVariable | ( | Variable * | input1, |
bool | parallel = 0 , |
||
bool | set_parallel_missing_output = 0 , |
||
Vec | parallel_missing_outputs = Vec(0) |
||
) |
Definition at line 55 of file IsMissingVariable.cc.
: inherited(input1, parall?input1->length():1, parall?input1->width():1), parallel(parall), set_parallel_missing_output(the_set_parallel_missing_output), parallel_missing_outputs(the_parallel_missing_outputs) {}
string PLearn::IsMissingVariable::_classname_ | ( | ) | [static] |
Reimplemented from PLearn::UnaryVariable.
Definition at line 53 of file IsMissingVariable.cc.
OptionList & PLearn::IsMissingVariable::_getOptionList_ | ( | ) | [static] |
Reimplemented from PLearn::UnaryVariable.
Definition at line 53 of file IsMissingVariable.cc.
RemoteMethodMap & PLearn::IsMissingVariable::_getRemoteMethodMap_ | ( | ) | [static] |
Reimplemented from PLearn::UnaryVariable.
Definition at line 53 of file IsMissingVariable.cc.
Reimplemented from PLearn::UnaryVariable.
Definition at line 53 of file IsMissingVariable.cc.
Object * PLearn::IsMissingVariable::_new_instance_for_typemap_ | ( | ) | [static] |
Reimplemented from PLearn::UnaryVariable.
Definition at line 53 of file IsMissingVariable.cc.
StaticInitializer IsMissingVariable::_static_initializer_ & PLearn::IsMissingVariable::_static_initialize_ | ( | ) | [static] |
Reimplemented from PLearn::UnaryVariable.
Definition at line 53 of file IsMissingVariable.cc.
void PLearn::IsMissingVariable::bprop | ( | ) | [virtual] |
Nothing to do by default.
Reimplemented from PLearn::UnaryVariable.
Definition at line 117 of file IsMissingVariable.cc.
{}
void PLearn::IsMissingVariable::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 69 of file IsMissingVariable.cc.
References PLearn::UnaryVariable::build(), and build_().
{ inherited::build(); build_(); }
void PLearn::IsMissingVariable::build_ | ( | ) | [private] |
This does the actual building.
Reimplemented from PLearn::UnaryVariable.
Definition at line 75 of file IsMissingVariable.cc.
References PLearn::UnaryVariable::input, PLearn::TVec< T >::length(), parallel_missing_outputs, and PLERROR.
Referenced by build().
{ if(parallel_missing_outputs.length() != input->size()) PLERROR("In IsMissingVariable::build_(): parallel_missing_outputs' size is different from input size."); }
string PLearn::IsMissingVariable::classname | ( | ) | const [virtual] |
Reimplemented from PLearn::UnaryVariable.
Definition at line 53 of file IsMissingVariable.cc.
void PLearn::IsMissingVariable::declareOptions | ( | OptionList & | ol | ) | [static] |
Declare options (data fields) for the class.
Redefine this in subclasses: call declareOption
(...) for each option, and then call inherited::declareOptions(options)
. Please call the inherited
method AT THE END to get the options listed in a consistent order (from most recently defined to least recently defined).
static void MyDerivedClass::declareOptions(OptionList& ol) { declareOption(ol, "inputsize", &MyObject::inputsize_, OptionBase::buildoption, "The size of the input; it must be provided"); declareOption(ol, "weights", &MyObject::weights, OptionBase::learntoption, "The learned model weights"); inherited::declareOptions(ol); }
ol | List of options that is progressively being constructed for the current class. |
Reimplemented from PLearn::UnaryVariable.
Definition at line 60 of file IsMissingVariable.cc.
References PLearn::OptionBase::buildoption, PLearn::declareOption(), PLearn::UnaryVariable::declareOptions(), parallel, parallel_missing_outputs, and set_parallel_missing_output.
{ declareOption(ol, "parallel", &IsMissingVariable::parallel, OptionBase::buildoption, ""); inherited::declareOptions(ol); declareOption(ol, "parallel_missing_outputs", &IsMissingVariable::parallel_missing_outputs, OptionBase::buildoption, ""); declareOption(ol, "set_parallel_missing_output", &IsMissingVariable::set_parallel_missing_output, OptionBase::buildoption, ""); inherited::declareOptions(ol); }
static const PPath& PLearn::IsMissingVariable::declaringFile | ( | ) | [inline, static] |
Reimplemented from PLearn::UnaryVariable.
Definition at line 78 of file IsMissingVariable.h.
{ return string("IsMissingVariable ()"); }
IsMissingVariable * PLearn::IsMissingVariable::deepCopy | ( | CopiesMap & | copies | ) | const [virtual] |
Reimplemented from PLearn::UnaryVariable.
Definition at line 53 of file IsMissingVariable.cc.
void PLearn::IsMissingVariable::fprop | ( | ) | [virtual] |
Nothing to do by default.
Reimplemented from PLearn::UnaryVariable.
Definition at line 90 of file IsMissingVariable.cc.
References i, PLearn::UnaryVariable::input, PLearn::Variable::nelems(), parallel, parallel_missing_outputs, set_parallel_missing_output, and PLearn::Variable::valuedata.
{ if (parallel) { if(!set_parallel_missing_output) for(int i=0; i<nelems(); i++) valuedata[i] = finite(input->valuedata[i]); else for(int i=0; i<nelems(); i++) { if(!finite(input->valuedata[i])) valuedata[i] = parallel_missing_outputs[i]; else valuedata[i] = input->valuedata[i]; } } else { bool nomissing=true; for(int i=0; i<nelems(); i++) nomissing = nomissing && finite(input->valuedata[i]); valuedata[0] = !nomissing; } }
OptionList & PLearn::IsMissingVariable::getOptionList | ( | ) | const [virtual] |
Reimplemented from PLearn::UnaryVariable.
Definition at line 53 of file IsMissingVariable.cc.
OptionMap & PLearn::IsMissingVariable::getOptionMap | ( | ) | const [virtual] |
Reimplemented from PLearn::UnaryVariable.
Definition at line 53 of file IsMissingVariable.cc.
RemoteMethodMap & PLearn::IsMissingVariable::getRemoteMethodMap | ( | ) | const [virtual] |
Reimplemented from PLearn::UnaryVariable.
Definition at line 53 of file IsMissingVariable.cc.
virtual string PLearn::IsMissingVariable::info | ( | ) | const [inline, virtual] |
Returns a bit more informative string about object (default returns classname())
Reimplemented from PLearn::Object.
Definition at line 84 of file IsMissingVariable.h.
{ return string("IsMissingVariable ()"); }
void PLearn::IsMissingVariable::makeDeepCopyFromShallowCopy | ( | CopiesMap & | copies | ) | [virtual] |
Transforms a shallow copy into a deep copy.
Reimplemented from PLearn::UnaryVariable.
Definition at line 121 of file IsMissingVariable.cc.
References PLearn::deepCopyField(), PLearn::UnaryVariable::makeDeepCopyFromShallowCopy(), and parallel_missing_outputs.
{ inherited::makeDeepCopyFromShallowCopy(copies); deepCopyField(parallel_missing_outputs, copies); //PLERROR("IsMissingVariable::makeDeepCopyFromShallowCopy not fully (correctly) implemented yet!"); }
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 81 of file IsMissingVariable.cc.
References PLearn::UnaryVariable::input, PLearn::Var::length(), parallel, and PLearn::Var::width().
{ if (input) { l = parallel ? input->length() : 1; w = parallel ? input->width() : 1; } else l = w = 0; }
void PLearn::IsMissingVariable::symbolicBprop | ( | ) | [virtual] |
compute a piece of new Var graph that represents the symbolic derivative of this Var
Reimplemented from PLearn::Variable.
Definition at line 119 of file IsMissingVariable.cc.
{}
Reimplemented from PLearn::UnaryVariable.
Definition at line 78 of file IsMissingVariable.h.
bool PLearn::IsMissingVariable::parallel [protected] |
if true then output 1 value per input, otherwise output 1 if ANY of the inputs is missing
Definition at line 59 of file IsMissingVariable.h.
Referenced by declareOptions(), fprop(), and recomputeSize().
Output value when input is missing (NaN)
Definition at line 65 of file IsMissingVariable.h.
Referenced by build_(), declareOptions(), fprop(), and makeDeepCopyFromShallowCopy().
Indication that, instead of outputing 0 if the input value is NaN, 1 otherwise, this variable will output parallel_missing_output if the input value is NaN, or the actual input value otherwise.
Definition at line 63 of file IsMissingVariable.h.
Referenced by declareOptions(), and fprop().