本文整理汇总了C++中HMM::Emission方法的典型用法代码示例。如果您正苦于以下问题:C++ HMM::Emission方法的具体用法?C++ HMM::Emission怎么用?C++ HMM::Emission使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HMM
的用法示例。
在下文中一共展示了HMM::Emission方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SaveHMM
void SaveHMM(const HMM<gmm::GMM<> >& hmm,
util::SaveRestoreUtility& sr)
{
std::string type = "gmm";
size_t states = hmm.Transition().n_rows;
sr.SaveParameter(type, "hmm_type");
sr.SaveParameter(states, "hmm_states");
sr.SaveParameter(hmm.Transition(), "hmm_transition");
// Now the emissions.
for (size_t i = 0; i < states; ++i)
{
// Generate name.
std::stringstream s;
s << "hmm_emission_" << i << "_gaussians";
sr.SaveParameter(hmm.Emission()[i].Gaussians(), s.str());
s.str("");
s << "hmm_emission_" << i << "_weights";
sr.SaveParameter(hmm.Emission()[i].Weights(), s.str());
for (size_t g = 0; g < hmm.Emission()[i].Gaussians(); ++g)
{
s.str("");
s << "hmm_emission_" << i << "_gaussian_" << g << "_mean";
sr.SaveParameter(hmm.Emission()[i].Means()[g], s.str());
s.str("");
s << "hmm_emission_" << i << "_gaussian_" << g << "_covariance";
sr.SaveParameter(hmm.Emission()[i].Covariances()[g], s.str());
}
}
}
示例2: LoadHMM
void LoadHMM(HMM<distribution::GaussianDistribution>& hmm,
util::SaveRestoreUtility& sr)
{
std::string type;
size_t states;
sr.LoadParameter(type, "hmm_type");
if (type != "gaussian")
{
Rcpp::Rcout << "Cannot load non-Gaussian HMM (of type " << type << ") as "
<< "a Gaussian HMM!" << std::endl;
}
sr.LoadParameter(states, "hmm_states");
// Load transition matrix.
sr.LoadParameter(hmm.Transition(), "hmm_transition");
// Now each emission distribution.
hmm.Emission().resize(states);
for (size_t i = 0; i < states; ++i)
{
std::stringstream s;
s << "hmm_emission_mean_" << i;
sr.LoadParameter(hmm.Emission()[i].Mean(), s.str());
s.str("");
s << "hmm_emission_covariance_" << i;
sr.LoadParameter(hmm.Emission()[i].Covariance(), s.str());
}
hmm.Dimensionality() = hmm.Emission()[0].Mean().n_elem;
}