本文整理汇总了C++中CFactor::GetDomainSize方法的典型用法代码示例。如果您正苦于以下问题:C++ CFactor::GetDomainSize方法的具体用法?C++ CFactor::GetDomainSize怎么用?C++ CFactor::GetDomainSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CFactor
的用法示例。
在下文中一共展示了CFactor::GetDomainSize方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Learn
void CEMLearningEngine::Learn()
{
CStaticGraphicalModel *pGrModel = this->GetStaticModel();
PNL_CHECK_IS_NULL_POINTER(pGrModel);
PNL_CHECK_LEFT_BORDER(GetNumEv() - GetNumberProcEv() , 1);
CInfEngine *pInfEng = NULL;
if (m_pInfEngine)
{
pInfEng = m_pInfEngine;
}
else
{
if (!m_bAllObserved)
{
pInfEng = CJtreeInfEngine::Create(pGrModel);
m_pInfEngine = pInfEng;
}
}
float loglik = 0.0f;
int nFactors = pGrModel->GetNumberOfFactors();
const CEvidence *pEv;
CFactor *pFactor;
int iteration = 0;
int ev;
bool IsCastNeed = false;
int i;
for( i = 0; i < nFactors; i++ )
{
pFactor = pGrModel->GetFactor(i);
EDistributionType dt = pFactor->GetDistributionType();
if ( dt == dtSoftMax ) IsCastNeed = true;
}
float ** full_evid = NULL;
if (IsCastNeed)
{
BuildFullEvidenceMatrix(&full_evid);
}
if (IsAllObserved())
{
int i;
float **evid = NULL;
EDistributionType dt;
CFactor *factor = NULL;
for (i = 0; i < nFactors; i++)
{
factor = pGrModel->GetFactor(i);
dt = factor->GetDistributionType();
if (dt != dtSoftMax)
{
factor->UpdateStatisticsML(&m_Vector_pEvidences[GetNumberProcEv()],
GetNumEv() - GetNumberProcEv());
}
else
{
intVector family;
family.resize(0);
pGrModel->GetGraph()->GetParents(i, &family);
family.push_back(i);
CSoftMaxCPD* SoftMaxFactor = static_cast<CSoftMaxCPD*>(factor);
SoftMaxFactor->BuildCurrentEvidenceMatrix(&full_evid,
&evid,family,m_Vector_pEvidences.size());
SoftMaxFactor->InitLearnData();
SoftMaxFactor->SetMaximizingMethod(m_MaximizingMethod);
SoftMaxFactor->MaximumLikelihood(evid, m_Vector_pEvidences.size(),
0.00001f, 0.01f);
SoftMaxFactor->CopyLearnDataToDistrib();
for (int k = 0; k < factor->GetDomainSize(); k++)
{
delete [] evid[k];
}
delete [] evid;
}
}
m_critValue.push_back(UpdateModel());
}
else
{
bool bContinue;
const CPotential * pot;
/* bool IsCastNeed = false;
int i;
for( i = 0; i < nFactors; i++ )
{
pFactor = pGrModel->GetFactor(i);
EDistributionType dt = pFactor->GetDistributionType();
if ( dt == dtSoftMax ) IsCastNeed = true;
}
float ** full_evid;
if (IsCastNeed)
//.........这里部分代码省略.........