C# Unity ML代理-简单逻辑“;及;大门示例-未完成任何插曲

C# Unity ML代理-简单逻辑“;及;大门示例-未完成任何插曲,c#,unity3d,machine-learning,ml-agent,C#,Unity3d,Machine Learning,Ml Agent,我试图创建一个非常简单的示例,在这个示例中,我用“和”门值来训练代理,即 1,0 = 0 1,1 = 1 0,0 = 0 0,1 = 0 我知道这是一个非常奇怪的测试项目,但我需要检查我是否可以在不需要游戏对象的情况下使用ML来评估数据 我已经遵循了这个项目中包含的“基本”示例,但我无法让它工作。我已经在下面发布了我的代码。任何帮助都将不胜感激 using System.Collections; using System.Collections.Generic; using UnityEngi

我试图创建一个非常简单的示例,在这个示例中,我用“和”门值来训练代理,即

1,0 = 0
1,1 = 1
0,0 = 0
0,1 = 0
我知道这是一个非常奇怪的测试项目,但我需要检查我是否可以在不需要游戏对象的情况下使用ML来评估数据

我已经遵循了这个项目中包含的“基本”示例,但我无法让它工作。我已经在下面发布了我的代码。任何帮助都将不胜感激

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using MLAgents;
using UnityEngine.UI;

public class TestAgent : Agent {

    public Text text;

    public List<float[]> inputs = new List<float[]>();
    public List<float[]> answers = new List<float[]>();

    float expectedAnswer;
    float[] inp;
    int rec;

    private void Start()
    {
        inputs.Add(new float[] { 0, 0 });
        answers.Add(new float[] { 0 });

        inputs.Add(new float[] { 1, 1 });
        answers.Add(new float[] { 1 });

        inputs.Add(new float[] { 1, 0 });
        answers.Add(new float[] { 0 });

        inputs.Add(new float[] { 0, 1 });
        answers.Add(new float[] { 0 });
    }

    public override void CollectObservations()
    {
        AddVectorObs(inp);
    }

    public override void AgentAction(float[] vectorAction, string textAction)
    {
        var movement = (int)vectorAction[0];

        text.text += ", Result = " + movement;

        // Time penalty
        AddReward(-0.05f);

        if ((int)movement == (int)expectedAnswer){
            AddReward(1f);
            Done();
        }
        else{
            AddReward(-1f);
            Done();
        }
    }

    public override void AgentOnDone()
    {
        base.AgentOnDone();
        Debug.Log("agent is done");
    }

    public override void AgentReset()
    {
        //this is where we submit the input data, i think
        rec = Random.Range(0, inputs.Count);
        inp = inputs[rec];
        expectedAnswer = answers[rec][0];
        text.text = "Inputs = [" + inp[0] + "," + inp[1] + "], Expecting = " + expectedAnswer;
    }

}
使用系统集合;
使用System.Collections.Generic;
使用UnityEngine;
使用MLA试剂;
使用UnityEngine.UI;
公共类测试代理:代理{
公共文本;
公共列表输入=新列表();
公共列表答案=新列表();
浮动预期答案;
浮动[]inp;
int rec;
私有void Start()
{
Add(新的浮点[]{0,0});
添加(新浮点[]{0});
Add(新的浮点[]{1,1});
添加(新浮点[]{1});
Add(新的浮点[]{1,0});
添加(新浮点[]{0});
Add(新的浮点[]{0,1});
添加(新浮点[]{0});
}
公共覆盖无效
{
AddVectorObs(inp);
}
公共重写void代理(float[]向量操作,字符串textAction)
{
变量移动=(int)向量动作[0];
text.text+=”,Result=“+移动;
//时间惩罚
额外报酬(-0.05华氏度);
如果((int)移动==(int)预期回答){
添加奖励(1f);
完成();
}
否则{
增加奖励(-1f);
完成();
}
}
public override void AgentOnDone()
{
base.AgentOnDone();
Log(“代理完成”);
}
公共覆盖无效代理集()
{
//我想这就是我们提交输入数据的地方
rec=随机范围(0,输入计数);
inp=输入[rec];
预期答案=答案[rec][0];
text.text=“Inputs=[”+inp[0]+”,“+inp[1]+”],Expecting=“+expectedAnswer;
}
}
更新 抱歉,我忘了提及,我在mac上按照unity ml GitHub页面上的安装指南安装了python,所以我只需运行“mlagents learn config/trainer\u config.yaml--run id=firstrun--train”,然后在unity中按play按钮开始训练过程

在终端窗口中,我得到了关于培训过程的反馈,起初,当我得到一份带有奖励值的打印输出时,一切似乎正常,但在下一份打印输出上,它说“自上次总结以来,没有完成任何一集”,但我不知道这意味着什么,也不知道问题是什么

我按照unity ml项目中的“基本”示例的要求在场景中设置了大脑和学院,但由于某些原因,它不起作用,但所有示例都起作用。我猜这是我的代码中的某个内容,而不是我的配置,但我不知道是什么。

我在代码中的任何地方都没有看到对“插曲”的引用。另外,请详细说明“但我无法让它工作”