XMM - Probabilistic Models for Motion Recognition and Mapping

Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | Friends | List of all members
xmm::SingleClassGMM Class Reference

Single-Class Gaussian Mixture Model. More...

#include <xmmGmmSingleClass.hpp>

Inheritance diagram for xmm::SingleClassGMM:
[legend]
Collaboration diagram for xmm::SingleClassGMM:
[legend]

Public Member Functions

 SingleClassGMM (std::shared_ptr< SharedParameters > p=NULL)
 Constructor. More...
 
 SingleClassGMM (SingleClassGMM const &src)
 Copy constructor. More...
 
 SingleClassGMM (std::shared_ptr< SharedParameters > p, Json::Value const &root)
 Copy constructor. More...
 
SingleClassGMMoperator= (SingleClassGMM const &src)
 Assignment. More...
 
Performance
void reset ()
 Resets the fitering process (recognition or regression) More...
 
double filter (std::vector< float > const &observation)
 filters a incoming observation (performs recognition or regression) More...
 
Json I/O
Json::Value toJson () const
 Write the object to a JSON Structure. More...
 
void fromJson (Json::Value const &root)
 Read the object from a JSON Structure. More...
 
Training
bool isTraining () const
 Checks if the model is training. More...
 
void train (TrainingSet *trainingSet)
 Main training method based on the EM algorithm. More...
 
void cancelTraining ()
 Cancels the training process : sets a flag so that the training stops at the next possible exit in the training process. More...
 
Python File I/O
void writeFile (char *fileName) const
 write method for python wrapping ('write' keyword forbidden, name has to be different) More...
 
void readFile (char *fileName)
 read method for python wrapping ('read' keyword forbidden, name has to be different) More...
 
std::string __str__ () const
 "print" method for python => returns the results of write method More...
 

Public Attributes

ClassParameters< GMMparameters
 Convert to bimodal GMM in place. More...
 
ClassResults< GMMresults
 Results of the filtering process (recognition & regression) More...
 
std::vector< GaussianDistributioncomponents
 Vector of Gaussian Components. More...
 
std::vector< float > mixture_coeffs
 Mixture Coefficients. More...
 
std::vector< double > beta
 Beta probabilities: likelihood of each component. More...
 
std::string label
 label associated with the given model More...
 
std::shared_ptr< SharedParametersshared_parameters
 Pointer to the shared parameters owned by a multi-class model. More...
 
EventGenerator< TrainingEventtraining_events
 Generator for events monitoring the training process. More...
 
TrainingEvent training_status
 Event containing information on the current status of the training process. More...
 

Protected Member Functions

void allocate ()
 Allocate model parameters. More...
 
double obsProb (const float *observation, int mixtureComponent=-1) const
 Observation probability. More...
 
double obsProb_input (const float *observation_input, int mixtureComponent=-1) const
 Observation probability on the input modality. More...
 
double obsProb_bimodal (const float *observation_input, const float *observation_output, int mixtureComponent=-1) const
 Observation probability for bimodal mode. More...
 
void emAlgorithmInit (TrainingSet *trainingSet)
 Initialize the EM Training Algorithm. More...
 
double emAlgorithmUpdate (TrainingSet *trainingSet)
 Update Function of the EM algorithm. More...
 
void initParametersToDefault (std::vector< float > const &dataStddev)
 Initialize model parameters to default values. More...
 
void initMeansWithKMeans (TrainingSet *trainingSet)
 Initialize the means of the Gaussian components with a Biased K-means. More...
 
void initCovariances_fullyObserved (TrainingSet *trainingSet)
 Initialize the Covariances of the Gaussian components using a fully observed approximation. More...
 
void normalizeMixtureCoeffs ()
 Normalize mixture coefficients. More...
 
void addCovarianceOffset ()
 Add offset to the diagonal of the covariance matrices. More...
 
void updateInverseCovariances ()
 Update inverse covariances of each Gaussian component. More...
 
double likelihood (std::vector< float > const &observation, std::vector< float > const &observation_output=null_vector_float)
 Compute likelihood and estimate components probabilities. More...
 
void regression (std::vector< float > const &observation_input)
 Compute Gaussian Mixture Regression. More...
 
void updateResults ()
 update the content of the likelihood buffer and return average likelihood. More...
 
virtual void emAlgorithmTerminate ()
 Terminate the training algorithm. More...
 
bool emAlgorithmHasConverged (int step, double log_prob, double old_log_prob) const
 checks if the training has converged according to the object's EM stop criterion More...
 
bool cancelTrainingIfRequested ()
 checks if a cancel request has been sent and accordingly cancels the training process More...
 
void check_training () const
 Checks if the model is still training. More...
 

Protected Attributes

std::vector< double > current_regularization
 vector containing the regularization values over each dimension More...
 
CircularBuffer< double > likelihood_buffer_
 Likelihood buffer used for smoothing. More...
 
std::mutex training_mutex_
 Mutex used in Concurrent Mode. More...
 
bool is_training_
 defines if the model is being trained. More...
 
bool cancel_training_
 defines if the model received a request to cancel training More...
 

Friends

template<typename SingleClassModel , typename ModelType >
class Model
 
class SingleClassHMM
 
class HierarchicalHMM
 

Detailed Description

Single-Class Gaussian Mixture Model.

Multivariate Gaussian Mixture Model. Supports Bimodal data and Gaussian Mixture Regression. Can be either autonomous or a state of a HMM: defines observation probabilities for each state.

Constructor & Destructor Documentation

xmm::SingleClassGMM::SingleClassGMM ( std::shared_ptr< SharedParameters p = NULL)

Constructor.

Parameters
ppointer to a shared parameters object (owned by a Model)
xmm::SingleClassGMM::SingleClassGMM ( SingleClassGMM const &  src)

Copy constructor.

Parameters
srcSource GMM
xmm::SingleClassGMM::SingleClassGMM ( std::shared_ptr< SharedParameters p,
Json::Value const &  root 
)
explicit

Copy constructor.

Parameters
ppointer to a shared parameters object (owned by a Model)
rootJson structure

Member Function Documentation

std::string xmm::Writable::__str__ ( ) const
inlineinherited

"print" method for python => returns the results of write method

Warning
only defined if SWIGPYTHON is defined
void xmm::SingleClassGMM::addCovarianceOffset ( )
protected

Add offset to the diagonal of the covariance matrices.

Guarantees convergence through covariance matrix invertibility

void xmm::SingleClassGMM::allocate ( )
protectedvirtual

Allocate model parameters.

Implements xmm::SingleClassProbabilisticModel.

void xmm::SingleClassProbabilisticModel::cancelTraining ( )
inherited

Cancels the training process : sets a flag so that the training stops at the next possible exit in the training process.

Warning
the model is still training when this function returns. This function only requests the training process to cancel.
bool xmm::SingleClassProbabilisticModel::cancelTrainingIfRequested ( )
protectedinherited

checks if a cancel request has been sent and accordingly cancels the training process

Returns
true if the training has been canceled.
void xmm::SingleClassProbabilisticModel::check_training ( ) const
inlineprotectedinherited

Checks if the model is still training.

Exceptions
runtime_errorif the model is training.
bool xmm::SingleClassProbabilisticModel::emAlgorithmHasConverged ( int  step,
double  log_prob,
double  old_log_prob 
) const
protectedinherited

checks if the training has converged according to the object's EM stop criterion

Parameters
stepindex of the current step of the EM algorithm
log_problog-likelihood returned by the EM update
old_log_problog-likelihood returned by the EM update at the previous step
void xmm::SingleClassGMM::emAlgorithmInit ( TrainingSet trainingSet)
protectedvirtual

Initialize the EM Training Algorithm.

Initializes the Gaussian Components from the first phrase of the Training Set

Implements xmm::SingleClassProbabilisticModel.

void xmm::SingleClassProbabilisticModel::emAlgorithmTerminate ( )
protectedvirtualinherited

Terminate the training algorithm.

Reimplemented in xmm::SingleClassHMM.

double xmm::SingleClassGMM::emAlgorithmUpdate ( TrainingSet trainingSet)
protectedvirtual

Update Function of the EM algorithm.

Returns
likelihood of the data given the current parameters (E-step)

Implements xmm::SingleClassProbabilisticModel.

double xmm::SingleClassGMM::filter ( std::vector< float > const &  observation)
virtual

filters a incoming observation (performs recognition or regression)

the results of the inference process are stored in the results attribute

Parameters
observationobservation vector
Returns
likelihood of the observation

Implements xmm::SingleClassProbabilisticModel.

void xmm::SingleClassGMM::fromJson ( Json::Value const &  root)
virtual

Read the object from a JSON Structure.

Parameters
rootJSON value containing the object's information
Exceptions
JsonExceptionif the JSON value has a wrong format

Implements xmm::SingleClassProbabilisticModel.

void xmm::SingleClassGMM::initCovariances_fullyObserved ( TrainingSet trainingSet)
protected

Initialize the Covariances of the Gaussian components using a fully observed approximation.

void xmm::SingleClassGMM::initMeansWithKMeans ( TrainingSet trainingSet)
protected

Initialize the means of the Gaussian components with a Biased K-means.

void xmm::SingleClassGMM::initParametersToDefault ( std::vector< float > const &  dataStddev)
protected

Initialize model parameters to default values.

Mixture coefficients are then equiprobable

bool xmm::SingleClassProbabilisticModel::isTraining ( ) const
inherited

Checks if the model is training.

Returns
true if the model is training
double xmm::SingleClassGMM::likelihood ( std::vector< float > const &  observation,
std::vector< float > const &  observation_output = null_vector_float 
)
protected

Compute likelihood and estimate components probabilities.

If the model is bimodal, the likelihood is computed only on the input modality, except if 'observation_output' is specified. Updates the likelihood buffer used to smooth likelihoods.

Parameters
observationobservation vector (full size for unimodal, input modality for bimodal)
observation_outputobservation vector of the output modality
void xmm::SingleClassGMM::normalizeMixtureCoeffs ( )
protected

Normalize mixture coefficients.

double xmm::SingleClassGMM::obsProb ( const float *  observation,
int  mixtureComponent = -1 
) const
protected

Observation probability.

Parameters
observationobservation vector (must be of size 'dimension')
mixtureComponentindex of the mixture component. if unspecified or negative, full mixture observation probability is computed
Returns
likelihood of the observation given the model
Exceptions
out_of_rangeif the index of the Gaussian Mixture Component is out of bounds
runtime_errorif the Covariance Matrix is not invertible
double xmm::SingleClassGMM::obsProb_bimodal ( const float *  observation_input,
const float *  observation_output,
int  mixtureComponent = -1 
) const
protected

Observation probability for bimodal mode.

Parameters
observation_inputobservation vector of the input modality (must be of size 'dimension_input')
observation_outputobservation vector of the input output (must be of size 'dimension - dimension_input')
mixtureComponentindex of the mixture component. if unspecified or negative, full mixture observation probability is computed
Returns
likelihood of the observation of the input modality given the model
Exceptions
runtime_errorif the model is not bimodal
runtime_errorif the Covariance Matrix is not invertible
double xmm::SingleClassGMM::obsProb_input ( const float *  observation_input,
int  mixtureComponent = -1 
) const
protected

Observation probability on the input modality.

Parameters
observation_inputobservation vector of the input modality (must be of size 'dimension_input')
mixtureComponentindex of the mixture component. if unspecified or negative, full mixture observation probability is computed
Returns
likelihood of the observation of the input modality given the model
Exceptions
runtime_errorif the model is not bimodal
runtime_errorif the Covariance Matrix of the input modality is not invertible
xmm::SingleClassGMM & xmm::SingleClassGMM::operator= ( SingleClassGMM const &  src)

Assignment.

Parameters
srcSource GMM
void xmm::Writable::readFile ( char *  fileName)
inlineinherited

read method for python wrapping ('read' keyword forbidden, name has to be different)

Warning
only defined if SWIGPYTHON is defined
void xmm::SingleClassGMM::regression ( std::vector< float > const &  observation_input)
protected

Compute Gaussian Mixture Regression.

Estimates the output modality using covariance-based regression weighted by components' likelihood

Warning
the function does not estimates the likelihoods, use 'likelihood' before performing the regression.
Parameters
observation_inputobservation vector of the input modality
void xmm::SingleClassGMM::reset ( )
virtual

Resets the fitering process (recognition or regression)

Reimplemented from xmm::SingleClassProbabilisticModel.

Json::Value xmm::SingleClassGMM::toJson ( ) const
virtual

Write the object to a JSON Structure.

Returns
Json value containing the object's information

Reimplemented from xmm::SingleClassProbabilisticModel.

void xmm::SingleClassProbabilisticModel::train ( TrainingSet trainingSet)
inherited

Main training method based on the EM algorithm.

the method performs a loop over the pure virtual method emAlgorithmUpdate() until convergence. The emAlgorithmUpdate method computes both E and M steps of the EM algorithm.

Parameters
trainingSetTraining Set to train the model.
See also
emAlgorithmUpdate
void xmm::SingleClassGMM::updateInverseCovariances ( )
protected

Update inverse covariances of each Gaussian component.

Exceptions
runtime_errorif one of the covariance matrices is not invertible
void xmm::SingleClassGMM::updateResults ( )
protected

update the content of the likelihood buffer and return average likelihood.

The method also updates the cumulative log-likelihood computed over a window (cumulativeloglikelihood)

void xmm::Writable::writeFile ( char *  fileName) const
inlineinherited

write method for python wrapping ('write' keyword forbidden, name has to be different)

Warning
only defined if SWIGPYTHON is defined

Friends And Related Function Documentation

friend class HierarchicalHMM
friend
template<typename SingleClassModel , typename ModelType >
friend class Model
friend
friend class SingleClassHMM
friend

Member Data Documentation

std::vector<double> xmm::SingleClassGMM::beta

Beta probabilities: likelihood of each component.

bool xmm::SingleClassProbabilisticModel::cancel_training_
protectedinherited

defines if the model received a request to cancel training

std::vector<GaussianDistribution> xmm::SingleClassGMM::components

Vector of Gaussian Components.

std::vector<double> xmm::SingleClassGMM::current_regularization
protected

vector containing the regularization values over each dimension

computed by combining relative and absolute regularization with the training set

bool xmm::SingleClassProbabilisticModel::is_training_
protectedinherited

defines if the model is being trained.

std::string xmm::SingleClassProbabilisticModel::label
inherited

label associated with the given model

CircularBuffer<double> xmm::SingleClassProbabilisticModel::likelihood_buffer_
protectedinherited

Likelihood buffer used for smoothing.

std::vector<float> xmm::SingleClassGMM::mixture_coeffs

Mixture Coefficients.

ClassParameters<GMM> xmm::SingleClassGMM::parameters

Convert to bimodal GMM in place.

Parameters
dimension_inputdimension of the input modality
Exceptions
runtime_errorif the model is already bimodal
out_of_rangeif the requested input dimension is too large Convert to unimodal GMM in place
runtime_errorif the model is already unimodal extract a submodel with the given columns
Parameters
columnscolumns indices in the target order
Exceptions
runtime_errorif the model is training
out_of_rangeif the number or indices of the requested columns exceeds the current dimension
Returns
a GMM from the current model considering only the target columns extract the submodel of the input modality
Exceptions
runtime_errorif the model is training or if it is not bimodal
Returns
a unimodal GMM of the input modality from the current bimodal model extract the submodel of the output modality
Exceptions
runtime_errorif the model is training or if it is not bimodal
Returns
a unimodal GMM of the output modality from the current bimodal model extract the model with reversed input and output modalities
Exceptions
runtime_errorif the model is training or if it is not bimodal
Returns
a bimodal GMM that swaps the input and output modalities Model Parameters
ClassResults<GMM> xmm::SingleClassGMM::results

Results of the filtering process (recognition & regression)

std::shared_ptr<SharedParameters> xmm::SingleClassProbabilisticModel::shared_parameters
inherited

Pointer to the shared parameters owned by a multi-class model.

EventGenerator<TrainingEvent> xmm::SingleClassProbabilisticModel::training_events
inherited

Generator for events monitoring the training process.

std::mutex xmm::SingleClassProbabilisticModel::training_mutex_
protectedinherited

Mutex used in Concurrent Mode.

TrainingEvent xmm::SingleClassProbabilisticModel::training_status
inherited

Event containing information on the current status of the training process.


The documentation for this class was generated from the following files: