Hierarchical Hidden Markov Model for Continuous Recognition and Regression (Multi-class) More...
#include <xmmHierarchicalHmm.hpp>
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... | |
HierarchicalHMM & | operator= (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< HMM > | results |
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< SharedParameters > | shared_parameters |
Set of Parameters shared among classes. More... | |
Configuration< HMM > | configuration |
Configuration (default and class-specific parameters) More... | |
EventGenerator< TrainingEvent > | training_events |
Generator for training process events. More... | |
std::map< std::string, SingleClassHMM > | models |
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... | |
Hierarchical Hidden Markov Model for Continuous Recognition and Regression (Multi-class)
xmm::HierarchicalHMM::HierarchicalHMM | ( | bool | bimodal = false | ) |
Constructor.
bimodal | specifies if the model should be used for regression |
xmm::HierarchicalHMM::HierarchicalHMM | ( | HierarchicalHMM const & | src | ) |
Copy Constructor.
src | Source Model |
|
explicit |
Constructor from Json Structure.
root | Json Value |
|
inlineinherited |
"print" method for python => returns the results of write method
void xmm::HierarchicalHMM::addExitPoint | ( | int | state, |
float | proba | ||
) |
|
protectedvirtual |
Update training set for a specific label.
label | label of the sub-training set to update |
out_of_range | if the label does not exist |
Reimplemented from xmm::Model< SingleClassHMM, HMM >.
|
inlineinherited |
Cancels the training of all models.
|
inlineinherited |
Cancels the training of a given class.
label | label of the class to cancel |
|
inlineprotectedinherited |
Look for configuration changes and throws an exception if the model is not up to date.
|
inlineprotectedinherited |
Checks if the Model is still training.
runtime_error | if the Model is training. |
|
virtual |
Remove All models.
Reimplemented from xmm::Model< SingleClassHMM, HMM >.
|
inlinestatic |
Default exit transition for the highest level.
|
virtual |
filters a incoming observation (performs recognition or regression)
the results of the inference process are stored in the results attribute
observation | observation vector |
Reimplemented from xmm::Model< SingleClassHMM, HMM >.
|
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].
observation | observation 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 |
|
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].
observation | observation 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 |
|
virtual |
Read the object from a JSON Structure.
root | JSON value containing the object's information |
JsonException | if the JSON value has a wrong format |
Implements xmm::Writable.
|
inlineinherited |
Checks if a class exists.
label | class label |
|
inlineinherited |
Checks if a class exists.
label | class label |
|
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 >.
|
protected |
get instantaneous likelihood
get instantaneous likelihood on alpha variable for exit state exitNum.
exitNum | number of exit state (0=continue, 1=transition, 2=back to root). if -1, get likelihood over all exit states |
likelihoodVector | likelihood vector (size nbPrimitives) |
|
protected |
Normalize segment level prior and transition matrices.
|
inlineprotectedinherited |
Monitors the training of each Model of the group.
xmm::HierarchicalHMM & xmm::HierarchicalHMM::operator= | ( | HierarchicalHMM const & | src | ) |
Assignment.
src | Source Model |
|
inlineinherited |
read method for python wrapping ('read' keyword forbidden, name has to be different)
|
virtual |
Remove a specific class by label.
label | label of the class to remove |
Reimplemented from xmm::Model< SingleClassHMM, HMM >.
|
virtual |
Resets the fitering process (recognition or regression)
Reimplemented from xmm::Model< SingleClassHMM, HMM >.
|
inlineinherited |
Get the number of classes in the model.
|
virtual |
Write the object to a JSON Structure.
Reimplemented from xmm::Model< SingleClassHMM, HMM >.
|
inlinevirtualinherited |
Train all classes from the training set passed in argument.
trainingSet | Training Set |
|
inlinevirtualinherited |
Train a specific class from the training set passed in argument.
trainingSet | Training Set |
label | label of the class to train |
out_of_range | if the label does not exist |
runtime_error | if the dimensions of the training set don't match the dimensions of the current model |
|
inlineinherited |
Checks if the model is trained (training finished and not empty)
|
inlineinherited |
Checks if the model is still training.
|
protected |
Update exit probabilities of each sub-model.
|
protected |
ergodic learning update high-level prior probabilities -> equal prior probs
|
protected |
Update the results (Likelihoods)
|
protected |
ergodic learning: update high-level transition matrix
equal transition probabilities between primitive gestures
|
protected |
update high-level parameters when a new primitive is learned
updated parameters: prior probabilities + transition matrix
|
inlineinherited |
write method for python wrapping ('write' keyword forbidden, name has to be different)
|
protectedinherited |
locks the Model while the models are training Used in cancel method
|
inherited |
Configuration (default and class-specific parameters)
|
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)
|
protected |
Defines if the forward algorithm has been initialized.
|
protected |
intermediate Forward variable (used in Frontier algorithm)
|
protected |
intermediate Forward variable (used in Frontier algorithm)
|
protectedinherited |
specifies if a thread for joining the training process has been launched.
|
protectedinherited |
locks the Model while the models are training Used in cancel method
|
inherited |
models stored in a map. Each Model is associated with a label
|
protectedinherited |
Number of models that are still training.
std::vector<double> xmm::HierarchicalHMM::prior |
Prior probabilities of the models.
Convert to bimodal HierarchicalHMM in place.
dimension_input | dimension of the input modality |
runtime_error | if the model is already bimodal |
out_of_range | if the requested input dimension is too large Convert to unimodal HierarchicalHMM in place |
runtime_error | if the model is already unimodal extract a submodel with the given columns |
columns | columns indices in the target order |
runtime_error | if the model is training |
out_of_range | if the number or indices of the requested columns exceeds the current dimension |
runtime_error | if the model is training or if it is not bimodal |
runtime_error | if the model is training or if it is not bimodal |
runtime_error | if the model is training or if it is not bimodal |
|
inherited |
Set of Parameters shared among classes.
|
inherited |
Generator for training process events.
|
protectedinherited |
Training Threads.
std::vector<std::vector<double> > xmm::HierarchicalHMM::transition |
Transition probabilities between models.