XMM - Probabilistic Models for Motion Recognition and Mapping

Public Member Functions | Static Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | List of all members
xmm::HierarchicalHMM Class Reference

Hierarchical Hidden Markov Model for Continuous Recognition and Regression (Multi-class) More...

#include <xmmHierarchicalHmm.hpp>

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

Public Member Functions

 HierarchicalHMM (bool bimodal=false)
 Constructor. More...
 
 HierarchicalHMM (HierarchicalHMM const &src)
 Copy Constructor. More...
 
 HierarchicalHMM (Json::Value const &root)
 Constructor from Json Structure. More...
 
HierarchicalHMMoperator= (HierarchicalHMM const &src)
 Assignment. More...
 
Class Manipulation
virtual void removeClass (std::string const &label)
 Remove a specific class by label. More...
 
virtual void clear ()
 Remove All models. More...
 
Accessors
void addExitPoint (int state, float proba)
 
Performance
virtual void reset ()
 Resets the fitering process (recognition or regression) More...
 
virtual void filter (std::vector< float > const &observation)
 filters a incoming observation (performs recognition or regression) More...
 
Json I/O
virtual Json::Value toJson () const
 Write the object to a JSON Structure. More...
 
virtual void fromJson (Json::Value const &root)
 Read the object from a JSON Structure. More...
 
Class Manipulation
unsigned int size () const
 Get the number of classes in the model. More...
 
bool hasClass (std::string const &label) const
 Checks if a class exists. More...
 
int getIndex (std::string const &label) const
 Checks if a class exists. More...
 
Training
bool trained () const
 Checks if the model is trained (training finished and not empty) More...
 
bool training () const
 Checks if the model is still training. More...
 
virtual void train (TrainingSet *trainingSet)
 Train all classes from the training set passed in argument. More...
 
virtual void train (TrainingSet *trainingSet, std::string const &label)
 Train a specific class from the training set passed in argument. More...
 
void cancelTraining ()
 Cancels the training of all models. More...
 
void cancelTraining (std::string const &label)
 Cancels the training of a given class. 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...
 

Static Public Member Functions

static const double DEFAULT_EXITTRANSITION ()
 Default exit transition for the highest level. More...
 

Public Attributes

Results< HMMresults
 Convert to bimodal HierarchicalHMM in place. More...
 
std::vector< double > prior
 Prior probabilities of the models. More...
 
std::vector< double > exit_transition
 exit probabilities of the model (probability to finish and go back to the root) More...
 
std::vector< std::vector< double > > transition
 Transition probabilities between models. More...
 
std::shared_ptr< SharedParametersshared_parameters
 Set of Parameters shared among classes. More...
 
Configuration< HMMconfiguration
 Configuration (default and class-specific parameters) More...
 
EventGenerator< TrainingEventtraining_events
 Generator for training process events. More...
 
std::map< std::string, SingleClassHMMmodels
 models stored in a map. Each Model is associated with a label More...
 

Protected Member Functions

virtual void joinTraining ()
 Finishes the background training process by joining threads and deleting the models which training failed. More...
 
void updateTransitionParameters ()
 update high-level parameters when a new primitive is learned More...
 
void updatePrior ()
 ergodic learning update high-level prior probabilities -> equal prior probs More...
 
void updateTransition ()
 ergodic learning: update high-level transition matrix More...
 
void updateExitProbabilities ()
 Update exit probabilities of each sub-model. More...
 
virtual void addModelForClass (std::string const &label)
 Update training set for a specific label. More...
 
void normalizeTransitions ()
 Normalize segment level prior and transition matrices. More...
 
void forward_init (std::vector< float > const &observation)
 Initialization of the Forward Algorithm for the hierarchical HMM. see: Jules Francoise. Realtime Segmentation and Recognition of Gestures using Hierarchical Markov Models. Master’s Thesis, Université Pierre et Marie Curie, Ircam, 2011. [http://articles.ircam.fr/textes/Francoise11a/index.pdf]. More...
 
void forward_update (std::vector< float > const &observation)
 Update of the Forward Algorithm for the hierarchical HMM. see: Jules Francoise. Realtime Segmentation and Recognition of Gestures using Hierarchical Markov Models. Master’s Thesis, Université Pierre et Marie Curie, Ircam, 2011. [http://articles.ircam.fr/textes/Francoise11a/index.pdf]. More...
 
void likelihoodAlpha (int exitNum, std::vector< double > &likelihoodVector) const
 get instantaneous likelihood More...
 
void updateResults ()
 Update the results (Likelihoods) More...
 
void onTrainingEvent (TrainingEvent const &e)
 Monitors the training of each Model of the group. More...
 
void checkTraining () const
 Checks if the Model is still training. More...
 
void checkConfigurationChanges () const
 Look for configuration changes and throws an exception if the model is not up to date. More...
 

Protected Attributes

bool forward_initialized_
 Defines if the forward algorithm has been initialized. More...
 
std::vector< double > frontier_v1_
 intermediate Forward variable (used in Frontier algorithm) More...
 
std::vector< double > frontier_v2_
 intermediate Forward variable (used in Frontier algorithm) More...
 
std::map< std::string, std::thread > training_threads_
 Training Threads. More...
 
std::atomic< bool > cancel_required_
 locks the Model while the models are training Used in cancel method More...
 
std::atomic< bool > is_training_
 locks the Model while the models are training Used in cancel method More...
 
std::atomic< bool > is_joining_
 specifies if a thread for joining the training process has been launched. More...
 
unsigned int models_still_training_
 Number of models that are still training. More...
 
std::mutex event_mutex_
 Mutex that prevents concurrent calls to onEvent() More...
 

Detailed Description

Hierarchical Hidden Markov Model for Continuous Recognition and Regression (Multi-class)

Constructor & Destructor Documentation

xmm::HierarchicalHMM::HierarchicalHMM ( bool  bimodal = false)

Constructor.

Parameters
bimodalspecifies if the model should be used for regression
xmm::HierarchicalHMM::HierarchicalHMM ( HierarchicalHMM const &  src)

Copy Constructor.

Parameters
srcSource Model
xmm::HierarchicalHMM::HierarchicalHMM ( Json::Value const &  root)
explicit

Constructor from Json Structure.

Parameters
rootJson Value

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::HierarchicalHMM::addExitPoint ( int  state,
float  proba 
)
void xmm::HierarchicalHMM::addModelForClass ( std::string const &  label)
protectedvirtual

Update training set for a specific label.

Parameters
labellabel of the sub-training set to update
Exceptions
out_of_rangeif the label does not exist

Reimplemented from xmm::Model< SingleClassHMM, HMM >.

void xmm::Model< SingleClassHMM , HMM >::cancelTraining ( )
inlineinherited

Cancels the training of all models.

void xmm::Model< SingleClassHMM , HMM >::cancelTraining ( std::string const &  label)
inlineinherited

Cancels the training of a given class.

Parameters
labellabel of the class to cancel
void xmm::Model< SingleClassHMM , HMM >::checkConfigurationChanges ( ) const
inlineprotectedinherited

Look for configuration changes and throws an exception if the model is not up to date.

void xmm::Model< SingleClassHMM , HMM >::checkTraining ( ) const
inlineprotectedinherited

Checks if the Model is still training.

Exceptions
runtime_errorif the Model is training.
void xmm::HierarchicalHMM::clear ( )
virtual

Remove All models.

Reimplemented from xmm::Model< SingleClassHMM, HMM >.

static const double xmm::HierarchicalHMM::DEFAULT_EXITTRANSITION ( )
inlinestatic

Default exit transition for the highest level.

void xmm::HierarchicalHMM::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

Reimplemented from xmm::Model< SingleClassHMM, HMM >.

void xmm::HierarchicalHMM::forward_init ( std::vector< float > const &  observation)
protected

Initialization of the Forward Algorithm for the hierarchical HMM. see: Jules Francoise. Realtime Segmentation and Recognition of Gestures using Hierarchical Markov Models. Master’s Thesis, Université Pierre et Marie Curie, Ircam, 2011. [http://articles.ircam.fr/textes/Francoise11a/index.pdf].

Parameters
observationobservation vector. If the model is bimodal, this should be allocated for both modalities, and should contain the observation on the input modality. The predicted output will be appended to the input modality observation
void xmm::HierarchicalHMM::forward_update ( std::vector< float > const &  observation)
protected

Update of the Forward Algorithm for the hierarchical HMM. see: Jules Francoise. Realtime Segmentation and Recognition of Gestures using Hierarchical Markov Models. Master’s Thesis, Université Pierre et Marie Curie, Ircam, 2011. [http://articles.ircam.fr/textes/Francoise11a/index.pdf].

Parameters
observationobservation vector. If the model is bimodal, this should be allocated for both modalities, and should contain the observation on the input modality. The predicted output will be appended to the input modality observation
void xmm::HierarchicalHMM::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::Writable.

int xmm::Model< SingleClassHMM , HMM >::getIndex ( std::string const &  label) const
inlineinherited

Checks if a class exists.

Parameters
labelclass label
Returns
true if the class labeled 'label' exists
bool xmm::Model< SingleClassHMM , HMM >::hasClass ( std::string const &  label) const
inlineinherited

Checks if a class exists.

Parameters
labelclass label
Returns
true if the class labeled 'label' exists
void xmm::HierarchicalHMM::joinTraining ( )
protectedvirtual

Finishes the background training process by joining threads and deleting the models which training failed.

: updates transition parameters after joining

Reimplemented from xmm::Model< SingleClassHMM, HMM >.

void xmm::HierarchicalHMM::likelihoodAlpha ( int  exitNum,
std::vector< double > &  likelihoodVector 
) const
protected

get instantaneous likelihood

get instantaneous likelihood on alpha variable for exit state exitNum.

Parameters
exitNumnumber of exit state (0=continue, 1=transition, 2=back to root). if -1, get likelihood over all exit states
likelihoodVectorlikelihood vector (size nbPrimitives)
void xmm::HierarchicalHMM::normalizeTransitions ( )
protected

Normalize segment level prior and transition matrices.

void xmm::Model< SingleClassHMM , HMM >::onTrainingEvent ( TrainingEvent const &  e)
inlineprotectedinherited

Monitors the training of each Model of the group.

xmm::HierarchicalHMM & xmm::HierarchicalHMM::operator= ( HierarchicalHMM const &  src)

Assignment.

Parameters
srcSource Model
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::HierarchicalHMM::removeClass ( std::string const &  label)
virtual

Remove a specific class by label.

Parameters
labellabel of the class to remove

Reimplemented from xmm::Model< SingleClassHMM, HMM >.

void xmm::HierarchicalHMM::reset ( )
virtual

Resets the fitering process (recognition or regression)

Reimplemented from xmm::Model< SingleClassHMM, HMM >.

unsigned int xmm::Model< SingleClassHMM , HMM >::size ( ) const
inlineinherited

Get the number of classes in the model.

Returns
the number of classes in the model
Json::Value xmm::HierarchicalHMM::toJson ( ) const
virtual

Write the object to a JSON Structure.

Returns
Json value containing the object's information

Reimplemented from xmm::Model< SingleClassHMM, HMM >.

virtual void xmm::Model< SingleClassHMM , HMM >::train ( TrainingSet trainingSet)
inlinevirtualinherited

Train all classes from the training set passed in argument.

Parameters
trainingSetTraining Set
virtual void xmm::Model< SingleClassHMM , HMM >::train ( TrainingSet trainingSet,
std::string const &  label 
)
inlinevirtualinherited

Train a specific class from the training set passed in argument.

Parameters
trainingSetTraining Set
labellabel of the class to train
Exceptions
out_of_rangeif the label does not exist
runtime_errorif the dimensions of the training set don't match the dimensions of the current model
bool xmm::Model< SingleClassHMM , HMM >::trained ( ) const
inlineinherited

Checks if the model is trained (training finished and not empty)

bool xmm::Model< SingleClassHMM , HMM >::training ( ) const
inlineinherited

Checks if the model is still training.

void xmm::HierarchicalHMM::updateExitProbabilities ( )
protected

Update exit probabilities of each sub-model.

void xmm::HierarchicalHMM::updatePrior ( )
protected

ergodic learning update high-level prior probabilities -> equal prior probs

void xmm::HierarchicalHMM::updateResults ( )
protected

Update the results (Likelihoods)

void xmm::HierarchicalHMM::updateTransition ( )
protected

ergodic learning: update high-level transition matrix

equal transition probabilities between primitive gestures

void xmm::HierarchicalHMM::updateTransitionParameters ( )
protected

update high-level parameters when a new primitive is learned

updated parameters: prior probabilities + transition matrix

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

Member Data Documentation

std::atomic<bool> xmm::Model< SingleClassHMM , HMM >::cancel_required_
protectedinherited

locks the Model while the models are training Used in cancel method

Configuration<HMM > xmm::Model< SingleClassHMM , HMM >::configuration
inherited

Configuration (default and class-specific parameters)

std::mutex xmm::Model< SingleClassHMM , HMM >::event_mutex_
protectedinherited

Mutex that prevents concurrent calls to onEvent()

std::vector<double> xmm::HierarchicalHMM::exit_transition

exit probabilities of the model (probability to finish and go back to the root)

bool xmm::HierarchicalHMM::forward_initialized_
protected

Defines if the forward algorithm has been initialized.

std::vector<double> xmm::HierarchicalHMM::frontier_v1_
protected

intermediate Forward variable (used in Frontier algorithm)

std::vector<double> xmm::HierarchicalHMM::frontier_v2_
protected

intermediate Forward variable (used in Frontier algorithm)

std::atomic<bool> xmm::Model< SingleClassHMM , HMM >::is_joining_
protectedinherited

specifies if a thread for joining the training process has been launched.

std::atomic<bool> xmm::Model< SingleClassHMM , HMM >::is_training_
protectedinherited

locks the Model while the models are training Used in cancel method

std::map<std::string, SingleClassHMM > xmm::Model< SingleClassHMM , HMM >::models
inherited

models stored in a map. Each Model is associated with a label

unsigned int xmm::Model< SingleClassHMM , HMM >::models_still_training_
protectedinherited

Number of models that are still training.

std::vector<double> xmm::HierarchicalHMM::prior

Prior probabilities of the models.

Results<HMM> xmm::HierarchicalHMM::results

Convert to bimodal HierarchicalHMM 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 HierarchicalHMM 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 HierarchicalHMM 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 HierarchicalHMM 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 HierarchicalHMM that swaps the input and output modalities Results of the Filtering Process (Recognition + Regression)
std::shared_ptr<SharedParameters> xmm::Model< SingleClassHMM , HMM >::shared_parameters
inherited

Set of Parameters shared among classes.

EventGenerator<TrainingEvent> xmm::Model< SingleClassHMM , HMM >::training_events
inherited

Generator for training process events.

std::map<std::string, std::thread> xmm::Model< SingleClassHMM , HMM >::training_threads_
protectedinherited

Training Threads.

std::vector<std::vector<double> > xmm::HierarchicalHMM::transition

Transition probabilities between models.


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