Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members

PLearn::MixtureRandomVariable Class Reference

#include <RandomVar.h>

Inheritance diagram for PLearn::MixtureRandomVariable:

Inheritance graph
[legend]
Collaboration diagram for PLearn::MixtureRandomVariable:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 MixtureRandomVariable (const RVArray &components, const RandomVar &log_weights)
 MixtureRandomVariable *.

virtual char * classname ()
const RandomVarlog_weights ()
 convenience inline: actual weights = softmax(log_weights)

boollearn_the_weights ()
virtual Var logP (const Var &obs, const RVInstanceArray &RHS, RVInstanceArray *parameters_to_learn)
virtual Var ElogP (const Var &obs, RVInstanceArray &parameters_to_learn, const RVInstanceArray &RHS)
virtual void setValueFromParentsValue ()
virtual void EMUpdate ()
virtual void EMBprop (const Vec obs, real posterior)
virtual void EMEpochInitialize ()
 Initialization of an individual EMEpoch.

virtual void EMTrainingInitialize (const RVArray &parameters_to_learn)
 Initialization of EM training (before all the iterations start).

virtual bool isDiscrete ()
 most common default

virtual bool canStopEM ()
virtual void setKnownValues ()
virtual void unmarkAncestors ()
 clear not only the marked field but also that of parents

virtual void clearEMmarks ()

Protected Attributes

RVArray components
 component distributions.

Vec posteriors
 P(i-th component | obs), used in EM.

Vec sum_posteriors
 sum of posteriors over trianing data

VarArray componentsLogP
 result of logP call for each component

Var lw
 = log(softmax(log_weights()->value()))

Var logp
 result of last call to logP


Constructor & Destructor Documentation

PLearn::MixtureRandomVariable::MixtureRandomVariable const RVArray the_components,
const RandomVar logweights
 

MixtureRandomVariable *.

Definition at line 2018 of file RandomVar.cc.


Member Function Documentation

bool PLearn::MixtureRandomVariable::canStopEM  )  [virtual]
 

Has the distribution seen enough EM iterations to meaningfully stop EM iterative training? This is a way for a RandomVariable sub-class to force continuation of the EM iterations beyond the criteria given by the caller of EM. the default just propagates to the unmarked parents.

Reimplemented from PLearn::RandomVariable.

Definition at line 2183 of file RandomVar.cc.

References components, log_weights(), and PLearn::TVec< RandomVar >::size().

virtual char* PLearn::MixtureRandomVariable::classname  )  [inline, virtual]
 

Implements PLearn::RandomVariable.

Definition at line 1253 of file RandomVar.h.

void PLearn::MixtureRandomVariable::clearEMmarks  )  [virtual]
 

Reimplemented from PLearn::RandomVariable.

Definition at line 2221 of file RandomVar.cc.

References components, log_weights(), and PLearn::TVec< RandomVar >::size().

Var PLearn::MixtureRandomVariable::ElogP const Var obs,
RVInstanceArray parameters_to_learn,
const RVInstanceArray RHS
[virtual]
 

Definition at line 2057 of file RandomVar.cc.

References components, componentsLogP, PLearn::exp(), PLearn::TVec< T >::length(), PLearn::log(), log_weights(), PLearn::logadd(), PLearn::logP(), logp, lw, PLearn::marginalize(), posteriors, PLearn::softmax(), PLearn::Var::subVec(), PLearn::sum(), PLearn::RVInstanceArray::swap_v_and_Vvalue(), unmarkAncestors(), and PLearn::vconcat().

void PLearn::MixtureRandomVariable::EMBprop const Vec  obs,
real  posterior
[virtual]
 

************ EM STUFF ********** propagate posterior information to parents in order to perform an EMupdate at the end of an EMEpoch. In the case of mixture-like RVs and their components, the posterior is the probability of the component "this" given the observation "obs".

Implements PLearn::RandomVariable.

Definition at line 2133 of file RandomVar.cc.

References PLearn::apply(), components, componentsLogP, PLearn::TVec< T >::data(), PLearn::endl(), PLearn::exp(), learn_the_weights(), PLearn::Var::length(), logp, lw, posteriors, PLearn::safeexp(), PLearn::sum(), sum_posteriors, and PLearn::tRealFunc.

void PLearn::MixtureRandomVariable::EMEpochInitialize  )  [virtual]
 

Initialization of an individual EMEpoch.

the default just propagates to the unmarked parents

Reimplemented from PLearn::RandomVariable.

Definition at line 2123 of file RandomVar.cc.

References PLearn::TVec< T >::clear(), components, learn_the_weights(), PLearn::TVec< RandomVar >::size(), and sum_posteriors.

void PLearn::MixtureRandomVariable::EMTrainingInitialize const RVArray parameters_to_learn  )  [virtual]
 

Initialization of EM training (before all the iterations start).

the default just propagates to the unmarked parents

Reimplemented from PLearn::RandomVariable.

Definition at line 2113 of file RandomVar.cc.

References components, PLearn::TVec< RandomVar >::contains(), learn_the_weights(), log_weights(), and PLearn::TVec< RandomVar >::size().

void PLearn::MixtureRandomVariable::EMUpdate  )  [virtual]
 

update the fixed (non-random) parameters using internal learning mechanism, at end of an EMEpoch. the default just propagates to the unmarked parents.

Reimplemented from PLearn::RandomVariable.

Definition at line 2164 of file RandomVar.cc.

References PLearn::apply(), components, learn_the_weights(), log_weights(), PLearn::multiply(), posteriors, PLearn::safeflog(), PLearn::TVec< RandomVar >::size(), PLearn::sum(), and sum_posteriors.

bool PLearn::MixtureRandomVariable::isDiscrete  )  [virtual]
 

most common default

Reimplemented from PLearn::StochasticRandomVariable.

Definition at line 2192 of file RandomVar.cc.

References components.

bool& PLearn::MixtureRandomVariable::learn_the_weights  )  [inline]
 

Definition at line 1258 of file RandomVar.h.

Referenced by EMBprop(), EMEpochInitialize(), EMTrainingInitialize(), and EMUpdate().

const RandomVar& PLearn::MixtureRandomVariable::log_weights  )  [inline]
 

convenience inline: actual weights = softmax(log_weights)

Definition at line 1257 of file RandomVar.h.

Referenced by canStopEM(), clearEMmarks(), ElogP(), EMTrainingInitialize(), EMUpdate(), logP(), setKnownValues(), setValueFromParentsValue(), and unmarkAncestors().

Var PLearn::MixtureRandomVariable::logP const Var obs,
const RVInstanceArray RHS,
RVInstanceArray parameters_to_learn
[virtual]
 

Construct a Var that computes logP(This = obs | RHS ). This function SHOULD NOT be used directly, but is called by the global function logP (same argument), which does proper massaging of the network before and after this call.

Implements PLearn::RandomVariable.

Definition at line 2027 of file RandomVar.cc.

References components, componentsLogP, PLearn::ElogP(), PLearn::TVec< T >::length(), PLearn::log(), log_weights(), PLearn::logadd(), PLearn::logP(), logp, lw, PLearn::marginalize(), posteriors, PLearn::softmax(), PLearn::Var::subVec(), and PLearn::vconcat().

void PLearn::MixtureRandomVariable::setKnownValues  )  [virtual]
 

traverse the graph of ancestors of this node and mark nodes which are deterministic descendents of marked nodes while setting their "value" field as a function of their parents.

Reimplemented from PLearn::StochasticRandomVariable.

Definition at line 2197 of file RandomVar.cc.

References components, log_weights(), setValueFromParentsValue(), and PLearn::TVec< RandomVar >::size().

void PLearn::MixtureRandomVariable::setValueFromParentsValue  )  [virtual]
 

define the formula that gives a value to this RV given its parent's value (sets the value field). If the RV is stochastic, the formula may also be "stochastic" (using SampleVariable's to define the Var).

Implements PLearn::RandomVariable.

Definition at line 2106 of file RandomVar.cc.

References components, log_weights(), PLearn::softmax(), and PLearn::RVArray::values().

Referenced by setKnownValues().

void PLearn::MixtureRandomVariable::unmarkAncestors  )  [virtual]
 

clear not only the marked field but also that of parents

Reimplemented from PLearn::RandomVariable.

Definition at line 2209 of file RandomVar.cc.

References components, log_weights(), and PLearn::TVec< RandomVar >::size().

Referenced by ElogP().


Member Data Documentation

RVArray PLearn::MixtureRandomVariable::components [protected]
 

component distributions.

Definition at line 1247 of file RandomVar.h.

Referenced by canStopEM(), clearEMmarks(), ElogP(), EMBprop(), EMEpochInitialize(), EMTrainingInitialize(), EMUpdate(), isDiscrete(), logP(), setKnownValues(), setValueFromParentsValue(), and unmarkAncestors().

VarArray PLearn::MixtureRandomVariable::componentsLogP [protected]
 

result of logP call for each component

Definition at line 1282 of file RandomVar.h.

Referenced by ElogP(), EMBprop(), and logP().

Var PLearn::MixtureRandomVariable::logp [protected]
 

result of last call to logP

Definition at line 1284 of file RandomVar.h.

Referenced by ElogP(), EMBprop(), and logP().

Var PLearn::MixtureRandomVariable::lw [protected]
 

= log(softmax(log_weights()->value()))

Definition at line 1283 of file RandomVar.h.

Referenced by ElogP(), EMBprop(), and logP().

Vec PLearn::MixtureRandomVariable::posteriors [protected]
 

P(i-th component | obs), used in EM.

Definition at line 1278 of file RandomVar.h.

Referenced by ElogP(), EMBprop(), EMUpdate(), and logP().

Vec PLearn::MixtureRandomVariable::sum_posteriors [protected]
 

sum of posteriors over trianing data

Definition at line 1279 of file RandomVar.h.

Referenced by EMBprop(), EMEpochInitialize(), and EMUpdate().


The documentation for this class was generated from the following files:
Generated on Tue Aug 17 16:24:25 2004 for PLearn by doxygen 1.3.7