如何使用贝叶斯服务器为动态贝叶斯网络中的变量指定初始概率值

时间:2018-11-01 00:15:01

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

我正在尝试在Unity游戏中使用C#中的Bayes server创建一个动态的贝叶斯网络来进行参数学习。该实现基于此article

下图所示模型的简要说明:当玩家开始玩关卡时,我给他们分配了0.5的初始概率,他们已经知道他们正在学习的东西,在所示的网络中被表示为Prior节点。与相关的变量称为priorKnowledge。该先验节点链接到知识节点,该知识节点是表示潜在变量LearnRate的隐藏节点,需要在游戏过程中学习。该节点又连接到“问题”节点,该节点具有两种状态正确或不正确,具体取决于玩家是否正确回答了问题。根据先前节点和问题节点的状态,一旦清除了先前的级别,就可以计算学习率并将其用作下一级别的先验。 enter image description here

我有以下代码用于使用贝叶斯服务器库在C#中创建网络。但是,我需要设置priority的初始值,但找不到解决方法。 Variable类中没有可让我为其分配值的方法。我该怎么办?

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
    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));
}

0 个答案:

没有答案