本文整理汇总了C++中CBNet::AllocParameters方法的典型用法代码示例。如果您正苦于以下问题:C++ CBNet::AllocParameters方法的具体用法?C++ CBNet::AllocParameters怎么用?C++ CBNet::AllocParameters使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CBNet
的用法示例。
在下文中一共展示了CBNet::AllocParameters方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CreateFourNodeExampleNew
CBNet* CreateFourNodeExampleNew(void)
{
CBNet *pBNet;
const int nnodes = 4;
const int numberOfNodeTypes = 2;
int numOfNeigh[] = { 1, 1, 3, 1 };
int neigh0[] = { 2 };
int neigh1[] = { 2 };
int neigh2[] = { 0, 1, 3 };
int neigh3[] = { 2 };
ENeighborType orient0[] = { ntChild };
ENeighborType orient1[] = { ntChild };
ENeighborType orient2[] = { ntParent, ntParent, ntChild };
ENeighborType orient3[] = { ntParent };
int *neigh[] = { neigh0, neigh1, neigh2, neigh3 };
ENeighborType *orient[] = { orient0, orient1, orient2, orient3 };
CGraph *pGraph = CGraph::Create( nnodes, numOfNeigh, neigh, orient );
CNodeType *nodeTypes = new CNodeType [numberOfNodeTypes];
nodeTypes[0].SetType(1, 2);
nodeTypes[1].SetType(0, 1);
int *nodeAssociation = new int[nnodes];
nodeAssociation[0]=0;
nodeAssociation[1]=1;
nodeAssociation[2]=1;
nodeAssociation[3]=1;
pBNet = CBNet::Create(nnodes, numberOfNodeTypes, nodeTypes, nodeAssociation, pGraph);
CModelDomain* pMD = pBNet->GetModelDomain();
//number of parameters is the same as number of nodes - one CPD per node
// CFactor *myParams = new CFactor[1];
int *nodeNumbers = new int [nnodes];
int domain0[] = { 0 };
int domain1[] = { 1 };
int domain2[] = { 0, 1, 2 };
int domain3[] = { 2, 3 };
int *domains[] = { domain0, domain1, domain2, domain3 };
nodeNumbers[0] = 1;
nodeNumbers[1] = 1;
nodeNumbers[2] = 3;
nodeNumbers[3] = 2;
pBNet->AllocParameters();
CFactor *myParams = CTabularCPD::Create( domains[0], nodeNumbers[0], pMD );
// data creation for all CPDs of the model
float data0[] = { 0.5f, 0.5f };
myParams->AllocMatrix(data0, matTable);
pBNet->AttachParameter(myParams);
float mean0 = 0.0f;
float cov0 = 1.0f;
CGaussianCPD* pCPD = CGaussianCPD::Create( domain1, 1, pMD );
pCPD->AllocDistribution( &mean0, &cov0, 1.0f, NULL);
pBNet->AttachFactor(pCPD);
float mean1[] = { 8.0f };
float mean2[] = { 2.0f };
float cov1[] = { 1.0f };
float cov2[] = { 1.0f };
float weight[] = { 0.01f, 0.03f };
float weight1[] = { 0.01f };
const float *pData = weight;
const float *pData1 = weight1;
CGaussianCPD* pCPD1 = CGaussianCPD::Create( domain2, 3, pMD );
int ParentCom[] = { 0, 1 };
pCPD1->AllocDistribution( mean1, cov1, 0.5f, &pData, &ParentCom[0] );
pCPD1->AllocDistribution( mean2, cov2, 0.5f, &pData, &ParentCom[1] );
pBNet->AttachFactor(pCPD1);
CGaussianCPD* pCPD2 = CGaussianCPD::Create( domain3, 2, pMD );
pCPD2->AllocDistribution( mean1, cov1, 0.5f, &pData1 );
pBNet->AttachFactor(pCPD2);
delete [] nodeTypes;
return pBNet;
}