ArgumentException:包含任何连续变量的节点不能具有包含任何离散变量的子节点

时间:2018-11-01 21:23:12

标签: c# unity3d bayesian hidden-markov-models bayesian-networks

我正在尝试使用Bayes服务器中的C#代码表示以下网络。在网络中,我网络中的Prior和'Knowledge'节点是连续的,概率值为0到1,问题节点是离散的,只有两个状态正确或不正确(即问题是否正确回答或错误地)。 enter image description here

该网络在我的脚本中的实现如下。

// numberOfDistractors and levelId will be used later for added complexity in modeling
void InitializeNetworkForLevel(int numberOfDistractors, int levelId)
{
    beliefnet = new BayesServer.Network();

    // add an intial knowledge node
    priorKnowledge = new Variable("PriorKnowledge", VariableValueType.Continuous, VariableKind.Probability);
    // initialize the priorKnowledge value to 0.5 if level = 1, else set it to learn rate (may be here, or in the queryNetwork method)
    priorKnowledgeNode = new Node("Prior", priorKnowledge);
    beliefnet.Nodes.Add(priorKnowledgeNode);

    // add a knowledge node which is a latent variable (parameter to be learned from observed values
    learnRate = new Variable("LearnRate", VariableValueType.Continuous, VariableKind.Probability);
    knowledgeNode = new Node("Knowledge", learnRate);
    beliefnet.Nodes.Add(knowledgeNode);

    // add a link from prior node to knowledge node
    beliefnet.Links.Add(new Link(priorKnowledgeNode, knowledgeNode));

    // add a question node, which denotes the oberved variable whether the question is answered correctly or not
    // this node has two states, namely correct or incorrect
    State correct = new State("Correct");
    State inCorrect = new State("Inorrect");
    questionNode = new Node("Question", correct, inCorrect);
    beliefnet.Nodes.Add(questionNode);

    // add a link from knowledge node to question node
    beliefnet.Links.Add(new Link(knowledgeNode, questionNode));

    // We will use the RelevanceTree algorithm here, as it is optimized for parameter learning
    learning = new ParameterLearning(beliefnet, new RelevanceTreeInferenceFactory());
    learningOptions = new ParameterLearningOptions();
    QueryNetwork(true);
}

但是,创建网络并不是说具有连续变量的节点不能具有具有离散变量的子节点,而是要我离散化那些连续节点。但是,网络就是这样,我不确定是否可以更改它。我该怎么办?

  

ArgumentException:包含任何连续变量的节点不能   有包含任何离散变量的子节点。而是链接   可以反转(如果适用),或添加潜在的离散父级   并链接到它,或者可以离散化连续变量。   BayesServer.NetworkLinkCollection。 (BayesServer.Link)(在   :0)   BayesServer.NetworkLinkCollection.Insert(System.Int32索引,   BayesServer.Link项)(位于:0)   BayesServer.NetworkLinkCollection.Add(BayesServer.Link项)(在   :0)   BayesNet.InitializeNetworkForLevel(System.Int32 numberOfDistractors,   System.Int32 levelId)(在Assets / Scripts / BayesNet.cs:57)   BayesNet.Start()(位于Assets / Scripts / BayesNet.cs:22)

enter image description here

0 个答案:

没有答案