PLearn 0.1
|
Let define f(x) = (x-min)/(max-min) for min<=x<=max, then this variable is defined by [x1,x2,...,xn] |-> [ f(x1), 1-f(x1), f(x2), 1-f(x2), ... More...
#include <ProbabilityPairsVariable.h>
Public Member Functions | |
ProbabilityPairsVariable () | |
Default constructor, usually does nothing. | |
ProbabilityPairsVariable (Variable *input, real min, real max) | |
ProbabilityPairsVariable (Variable *input, real max) | |
ProbabilityPairsVariable (Variable *input) | |
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 string | classname () const |
virtual OptionList & | getOptionList () const |
virtual OptionMap & | getOptionMap () const |
virtual RemoteMethodMap & | getRemoteMethodMap () const |
virtual ProbabilityPairsVariable * | 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_ () |
ProbabilityPairsVariable. | |
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 | |
real | min |
### declare public option fields (such as build options) here Start your comments with Doxygen-compatible comments such as //! | |
real | max |
same as min but for upper bound | |
Static Public Attributes | |
static StaticInitializer | _static_initializer_ |
Static Protected Member Functions | |
static void | declareOptions (OptionList &ol) |
Declares the class options. | |
Private Types | |
typedef UnaryVariable | inherited |
Private Member Functions | |
void | build_ () |
This does the actual building. |
Let define f(x) = (x-min)/(max-min) for min<=x<=max, then this variable is defined by [x1,x2,...,xn] |-> [ f(x1), 1-f(x1), f(x2), 1-f(x2), ...
* ProbabilityPairsVariable * , f(xn), 1-f(xn) ]
This can be interpreted as pairs of probabilities
Definition at line 61 of file ProbabilityPairsVariable.h.
typedef UnaryVariable PLearn::ProbabilityPairsVariable::inherited [private] |
Reimplemented from PLearn::UnaryVariable.
Definition at line 63 of file ProbabilityPairsVariable.h.
PLearn::ProbabilityPairsVariable::ProbabilityPairsVariable | ( | ) |
Default constructor, usually does nothing.
Definition at line 53 of file ProbabilityPairsVariable.cc.
PLearn::ProbabilityPairsVariable::ProbabilityPairsVariable | ( | Variable * | input | ) |
string PLearn::ProbabilityPairsVariable::_classname_ | ( | ) | [static] |
Reimplemented from PLearn::UnaryVariable.
Definition at line 51 of file ProbabilityPairsVariable.cc.
OptionList & PLearn::ProbabilityPairsVariable::_getOptionList_ | ( | ) | [static] |
Reimplemented from PLearn::UnaryVariable.
Definition at line 51 of file ProbabilityPairsVariable.cc.
RemoteMethodMap & PLearn::ProbabilityPairsVariable::_getRemoteMethodMap_ | ( | ) | [static] |
Reimplemented from PLearn::UnaryVariable.
Definition at line 51 of file ProbabilityPairsVariable.cc.
Reimplemented from PLearn::UnaryVariable.
Definition at line 51 of file ProbabilityPairsVariable.cc.
Object * PLearn::ProbabilityPairsVariable::_new_instance_for_typemap_ | ( | ) | [static] |
Reimplemented from PLearn::UnaryVariable.
Definition at line 51 of file ProbabilityPairsVariable.cc.
StaticInitializer ProbabilityPairsVariable::_static_initializer_ & PLearn::ProbabilityPairsVariable::_static_initialize_ | ( | ) | [static] |
Reimplemented from PLearn::UnaryVariable.
Definition at line 51 of file ProbabilityPairsVariable.cc.
void PLearn::ProbabilityPairsVariable::bprop | ( | ) | [virtual] |
Nothing to do by default.
Reimplemented from PLearn::UnaryVariable.
Definition at line 101 of file ProbabilityPairsVariable.cc.
References i, PLearn::UnaryVariable::input, PLearn::Variable::length(), PLearn::Variable::matGradient, max, min, n, and PLearn::Var::width().
{ for(int n=0; n<length(); n++) for(int i=0; i<input->width(); i++) input->matGradient(n,i) += 1./(max-min)*(matGradient(n,2*i) - matGradient(n,2*i+1)); }
void PLearn::ProbabilityPairsVariable::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 115 of file ProbabilityPairsVariable.cc.
References PLearn::UnaryVariable::build(), and build_().
{ inherited::build(); build_(); }
void PLearn::ProbabilityPairsVariable::build_ | ( | ) | [private] |
This does the actual building.
Reimplemented from PLearn::UnaryVariable.
Definition at line 160 of file ProbabilityPairsVariable.cc.
Referenced by build(), and ProbabilityPairsVariable().
{ // ### 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::ProbabilityPairsVariable::classname | ( | ) | const [virtual] |
Reimplemented from PLearn::UnaryVariable.
Definition at line 51 of file ProbabilityPairsVariable.cc.
void PLearn::ProbabilityPairsVariable::declareOptions | ( | OptionList & | ol | ) | [static, protected] |
Declares the class options.
Reimplemented from PLearn::UnaryVariable.
Definition at line 135 of file ProbabilityPairsVariable.cc.
References PLearn::OptionBase::buildoption, PLearn::declareOption(), PLearn::UnaryVariable::declareOptions(), max, and min.
{ // ### 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) declareOption(ol, "min", &ProbabilityPairsVariable::min, OptionBase::buildoption, "The lower bound a value of the input should be. It will be used to calculate the corresponding probability of each input."); declareOption(ol, "max", &ProbabilityPairsVariable::max, OptionBase::buildoption, "analog to min"); // Now call the parent class' declareOptions inherited::declareOptions(ol); }
static const PPath& PLearn::ProbabilityPairsVariable::declaringFile | ( | ) | [inline, static] |
Reimplemented from PLearn::UnaryVariable.
Definition at line 107 of file ProbabilityPairsVariable.h.
:
//##### Protected Options ###############################################
ProbabilityPairsVariable * PLearn::ProbabilityPairsVariable::deepCopy | ( | CopiesMap & | copies | ) | const [virtual] |
Reimplemented from PLearn::UnaryVariable.
Definition at line 51 of file ProbabilityPairsVariable.cc.
void PLearn::ProbabilityPairsVariable::fprop | ( | ) | [virtual] |
Nothing to do by default.
Reimplemented from PLearn::UnaryVariable.
Definition at line 88 of file ProbabilityPairsVariable.cc.
References i, PLearn::UnaryVariable::input, PLearn::Var::length(), PLearn::Variable::matValue, max, min, n, and PLearn::Var::width().
{ real prob; for(int n=0; n<input->length(); n++) for(int i=0; i<input->width(); i++) { prob = (input->matValue(n,i)-min)/(max-min); matValue(n,2*i) = prob; matValue(n,2*i+1) = 1.-prob; } }
OptionList & PLearn::ProbabilityPairsVariable::getOptionList | ( | ) | const [virtual] |
Reimplemented from PLearn::UnaryVariable.
Definition at line 51 of file ProbabilityPairsVariable.cc.
OptionMap & PLearn::ProbabilityPairsVariable::getOptionMap | ( | ) | const [virtual] |
Reimplemented from PLearn::UnaryVariable.
Definition at line 51 of file ProbabilityPairsVariable.cc.
RemoteMethodMap & PLearn::ProbabilityPairsVariable::getRemoteMethodMap | ( | ) | const [virtual] |
Reimplemented from PLearn::UnaryVariable.
Definition at line 51 of file ProbabilityPairsVariable.cc.
void PLearn::ProbabilityPairsVariable::makeDeepCopyFromShallowCopy | ( | CopiesMap & | copies | ) | [virtual] |
Transforms a shallow copy into a deep copy.
Reimplemented from PLearn::UnaryVariable.
Definition at line 121 of file ProbabilityPairsVariable.cc.
References PLearn::UnaryVariable::makeDeepCopyFromShallowCopy().
{ inherited::makeDeepCopyFromShallowCopy(copies); // ### Call deepCopyField on all "pointer-like" fields // ### that you wish to be deepCopied rather than // ### shallow-copied. // ### ex: // deepCopyField(trainvec, copies); // ### If you want to deepCopy a Var field: // varDeepCopyField(somevariable, copies); }
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 78 of file ProbabilityPairsVariable.cc.
References PLearn::UnaryVariable::input, PLearn::Var::length(), and PLearn::Var::width().
{ if (input) { l = input->length(); // the computed length of this Var w = input->width()*2; // the computed width } else l = w = 0; }
Reimplemented from PLearn::UnaryVariable.
Definition at line 107 of file ProbabilityPairsVariable.h.
same as min but for upper bound
Definition at line 77 of file ProbabilityPairsVariable.h.
Referenced by bprop(), declareOptions(), and fprop().
### declare public option fields (such as build options) here Start your comments with Doxygen-compatible comments such as //!
the lower bound a value of the input should be it will be used to calculate the corresponding probability of each input
Definition at line 74 of file ProbabilityPairsVariable.h.
Referenced by bprop(), declareOptions(), and fprop().