1
試圖取代我的自定義實現高斯混合似然概率計算爲IPP程序,如ippsLogGaussMixture_32f_D2,但我不滿意,並不是undestand這個函數的結果,所以我想知道如何它處理我的輸入數據,所以我需要公式。需要IPP GMM函數的數學公式。像ippsLogGaussMixture_32f_D2()和其他
試圖取代我的自定義實現高斯混合似然概率計算爲IPP程序,如ippsLogGaussMixture_32f_D2,但我不滿意,並不是undestand這個函數的結果,所以我想知道如何它處理我的輸入數據,所以我需要公式。需要IPP GMM函數的數學公式。像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]);
}
}