12 #ifndef MLPACK_METHODS_HMM_HMM_MODEL_HPP 13 #define MLPACK_METHODS_HMM_HMM_MODEL_HPP 26 GaussianMixtureModelHMM,
27 DiagonalGaussianMixtureModelHMM
49 HMMModel(
const HMMType type = HMMType::DiscreteHMM) :
56 if (type == HMMType::DiscreteHMM)
58 else if (type == HMMType::GaussianHMM)
60 else if (type == HMMType::GaussianMixtureModelHMM)
62 else if (type == HMMType::DiagonalGaussianMixtureModelHMM)
74 if (type == HMMType::DiscreteHMM)
77 else if (type == HMMType::GaussianHMM)
80 else if (type == HMMType::GaussianMixtureModelHMM)
82 else if (type == HMMType::DiagonalGaussianMixtureModelHMM)
89 discreteHMM(other.discreteHMM),
90 gaussianHMM(other.gaussianHMM),
92 diagGMMHMM(other.diagGMMHMM)
94 other.type = HMMType::DiscreteHMM;
96 other.gaussianHMM = NULL;
98 other.diagGMMHMM = NULL;
118 if (type == HMMType::DiscreteHMM)
121 else if (type == HMMType::GaussianHMM)
124 else if (type == HMMType::GaussianMixtureModelHMM)
126 else if (type == HMMType::DiagonalGaussianMixtureModelHMM)
138 discreteHMM = other.discreteHMM;
139 gaussianHMM = other.gaussianHMM;
140 gmmHMM = other.gmmHMM;
141 diagGMMHMM = other.diagGMMHMM;
143 other.type = HMMType::DiscreteHMM;
145 other.gaussianHMM =
nullptr;
146 other.gmmHMM =
nullptr;
147 other.diagGMMHMM =
nullptr;
165 template<
typename ActionType,
166 typename ExtraInfoType>
169 if (type == HMMType::DiscreteHMM)
170 ActionType::Apply(*discreteHMM, x);
171 else if (type == HMMType::GaussianHMM)
172 ActionType::Apply(*gaussianHMM, x);
173 else if (type == HMMType::GaussianMixtureModelHMM)
174 ActionType::Apply(*gmmHMM, x);
175 else if (type == HMMType::DiagonalGaussianMixtureModelHMM)
176 ActionType::Apply(*diagGMMHMM, x);
180 template<
typename Archive>
183 ar(CEREAL_NVP(type));
186 if (cereal::is_loading<Archive>())
199 if (type == HMMType::DiscreteHMM)
201 else if (type == HMMType::GaussianHMM)
203 else if (type == HMMType::GaussianMixtureModelHMM)
205 else if (type == HMMType::DiagonalGaussianMixtureModelHMM)
210 HMMType Type() {
return type; }
void serialize(Archive &ar, const uint32_t)
Serialize the model.
Definition: hmm_model.hpp:181
HMMModel(HMMModel &&other)
Take ownership of another model.
Definition: hmm_model.hpp:87
Linear algebra utility functions, generally performed on matrices or vectors.
Definition: cv.hpp:1
HMMModel & operator=(HMMModel &&other)
Move assignment operator.
Definition: hmm_model.hpp:133
HMMModel(const HMMModel &other)
Copy another model.
Definition: hmm_model.hpp:67
HMMModel(const HMMType type=HMMType::DiscreteHMM)
Construct a model of the given type.
Definition: hmm_model.hpp:49
HMM< distribution::DiscreteDistribution > * DiscreteHMM()
Accessor methods for discreteHMM, gaussianHMM, gmmHMM, and diagGMMHMM.
Definition: hmm_model.hpp:231
~HMMModel()
Clean memory.
Definition: hmm_model.hpp:153
A class that represents a Hidden Markov Model with an arbitrary type of emission distribution.
Definition: hmm.hpp:85
A serializable HMM model that also stores the type.
Definition: hmm_model.hpp:33
#define CEREAL_POINTER(T)
Cereal does not support the serialization of raw pointer.
Definition: pointer_wrapper.hpp:96
void PerformAction(ExtraInfoType *x)
Given a functor type, perform that functor with the optional extra info on the HMM.
Definition: hmm_model.hpp:167
HMMModel & operator=(const HMMModel &other)
Copy assignment operator.
Definition: hmm_model.hpp:102