当前位置: 首页>>代码示例>>C++>>正文


C++ Accumulator::accumulateObservation方法代码示例

本文整理汇总了C++中Accumulator::accumulateObservation方法的典型用法代码示例。如果您正苦于以下问题:C++ Accumulator::accumulateObservation方法的具体用法?C++ Accumulator::accumulateObservation怎么用?C++ Accumulator::accumulateObservation使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Accumulator的用法示例。


在下文中一共展示了Accumulator::accumulateObservation方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: accumulate

// accumulate statistics
void DTAccumulator::accumulate(Alignment *alignment, MatrixBase<float> &mFeatures, bool bNumerator) {

	Accumulator *accumulator = NULL;
	double dOccupationTotal = 0.0;
	for(unsigned int t=0 ; t < alignment->getFrames() ; ++t) {
		FrameAlignment *frameAlignment = alignment->getFrameAlignment(t);
		VectorStatic<float> vFeatureVector = mFeatures.getRow(t);
		for(FrameAlignment::iterator it = frameAlignment->begin() ; it != frameAlignment->end() ; ++it) {
			double dOccupationNum = (*it)->dOccupation;
			HMMState *hmmState = m_hmmManager->getHMMState((*it)->iHMMState);
			// get Gaussian occupation from the mixture occupation
			
			// (1) compute the mixture likelihood (all Gaussian components)
			double dLikelihoodTotal = -DBL_MAX;
			int iGaussianComponents = hmmState->getMixture().getNumberComponents();
			double *dLikelihoodGaussian = new double[iGaussianComponents];
			for(int iGaussian = 0 ; iGaussian < iGaussianComponents ; ++iGaussian) {
				dLikelihoodGaussian[iGaussian] = hmmState->computeEmissionProbabilityGaussian(iGaussian,
					mFeatures.getRow(t).getData(),-1);
				dLikelihoodGaussian[iGaussian] += log(hmmState->getMixture()(iGaussian)->weight());
				dLikelihoodTotal = Numeric::logAddition(dLikelihoodTotal,dLikelihoodGaussian[iGaussian]);
			}
			// (2) accumulate statistics for each mixture component
			for(int iGaussian = 0 ; iGaussian < iGaussianComponents ; ++iGaussian) {
				
				double dProbGaussian = exp(dLikelihoodGaussian[iGaussian]-dLikelihoodTotal);
				assert(dProbGaussian >= 0.0);
				double dOccupationGaussian = dOccupationNum*dProbGaussian;
				unsigned int iKey = Accumulator::getPhysicalAccumulatorKey(hmmState->getId(),iGaussian);
				if (bNumerator) {
					accumulator = m_mAccumulatorNum[iKey];
				} else {
					accumulator = m_mAccumulatorDen[iKey];	
				}
				accumulator->accumulateObservation(vFeatureVector,dOccupationGaussian);
				dOccupationTotal += dOccupationGaussian;
			}
			delete [] dLikelihoodGaussian;
		}
	}	
	printf("accumulated: %12.6f\n",dOccupationTotal);
}
开发者ID:nlphacker,项目名称:bavieca,代码行数:43,代码来源:DTAccumulator.cpp


注:本文中的Accumulator::accumulateObservation方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。