gpt4 book ai didi

c++ - 需要 IPP GMM 函数的数学公式。像 ippsLogGaussMixture_32f_D2() 等

转载 作者:太空宇宙 更新时间:2023-11-04 14:17:45 26 4
gpt4 key购买 nike

试图将我的高斯混合似然概率计算的自定义实现替换为 IPP 程序,例如 ippsLogGaussMixture_32f_D2,但我不满意并且不理解此函数的结果,所以我想知道它如何处理我的输入数据,所以我需要公式。

最佳答案

好的,这是一个迟到的答案,我猜你可能已经继续前进了,但我不得不自己重新实现这些。我注意到我注意到我实现的 4 个功能中的每一个有多少变化。我不确定为什么我看到 LogGaussMixture 有如此大的变化,但它是相同的。

// This produces a similar result to ippsLogGaussMultiMix_32f_D2 with a very small error in the 5th or 6th decimal place.
template< typename Type > void LogGaussMultiMix( Type* pMeans, Type* pCVars, int step, Type* pFeatures, int featureWidth, Type* pDets, Type* pPostProbs, int gaussianNum )
{
for( int g = 0; g < gaussianNum; g++ )
{
Type sum = 0.0f;
for( int f = 0; f < featureWidth; f++ )
{
const Type kFeaturesMinusMean = pFeatures[f] - pMeans[(g * step) + f];
sum += (kFeaturesMinusMean * kFeaturesMinusMean) * pCVars[(g * step) + f];
}

pPostProbs[g] = (Type( -0.5 ) * sum) + pDets[g];
}
}

// This produces a similar result to ippsLogGaussMixture_32f_D2 but with quite a large error at the second decimal place (~0.05!)
template< typename Type > void LogGaussMixture( Type* pMeans, Type* pCVars, int step, Type* pFeatures, int featureWidth, Type* pDets, int gaussianNum, Type& out )
{
out = 1.0f;
for( int g = 0; g < gaussianNum; g++ )
{
Type sum = 0.0f;
for( int f = 0; f < featureWidth; f++ )
{
const Type kFeaturesMinusMean = pFeatures[f] - pMeans[(g * step) + f];
sum += (kFeaturesMinusMean * kFeaturesMinusMean) * pCVars[(g * step) + f];
}

const Type kPostProb = (Type( -0.5 ) * sum) + pDets[g];
out += std::log( Type( 1 ) + std::exp( kPostProb ) );
}
out = std::log( out );
}

// This function is similar to ippsUpdateGConst_32f with difference at the 5th decimal place.
template< typename Type > void UpdateGConst( Type* pCVars, int width, Type& det )
{
Type logSum = 0;
for( int i = 0; i < width; i++ )
{
logSum += std::log( pCVars[i] );
}

// ln( 2 * pi ) = 1.837877066409346;
det = (width * Type( 1.837877066409346 )) - logSum;
}

// This function is like ippsOutProbPreCalc_32f_I and has no discernible error.
template< typename Type > void OutProbPreCalc( Type* pWeight, Type* pDetIn, Type* pDetOut, int gaussianNum )
{
for( int g = 0; g < gaussianNum; g++ )
{
pDetOut[g] = pWeight[g] - (Type( 0.5 ) * pDetIn[g]);
}
}

关于c++ - 需要 IPP GMM 函数的数学公式。像 ippsLogGaussMixture_32f_D2() 等,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9888932/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com