Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Academy.Instance.EnvironmentStep() did not work!

Discussion in 'ML-Agents' started by wglxxx, May 13, 2020.

  1. wglxxx

    wglxxx

    Joined:
    Oct 27, 2018
    Posts:
    6
    This is my agent class, i call AddComponent<MyAgent >() to active it.
    When I call the function Academy.Instance.EnvironmentStep(), CollectDiscreteActionMasks() and OnActionReceived() is not executed.How can I perform the training process manually.
    Code (CSharp):
    1. class MyAgent :Agent
    2. {
    3.  private void Awake()
    4.  {
    5.    Academy.Instance.AutomaticSteppingEnabled = false;
    6.    BehaviorParameters bp = gameObject.GetComponent<BehaviorParameters>();
    7.    bp.BehaviorName = "Cha Behavior";
    8.    bp.BrainParameters.VectorObservationSize = 19 * 19 + 6;
    9.    bp.BrainParameters.NumStackedVectorObservations = 2;
    10.    bp.BrainParameters.VectorActionSize = new int[2] { 19 * 19 + 1, 19 * 19 + 1 };
    11.    MaxStep = 150;
    12.  }
    13.  public override void CollectObservations(VectorSensor sensor){...}
    14.  public override void CollectDiscreteActionMasks(DiscreteActionMasker actionMasker){...}
    15.  public override void OnActionReceived(float[] vectorAction){...}
    16. }
     
  2. TreyK-47

    TreyK-47

    Unity Technologies

    Joined:
    Oct 22, 2019
    Posts:
    1,810
    Flagging this for the team to have a look! Could you tell us which version of ML Agents you're using? Also, which versions of C# & Python? Thanks!
     
  3. wglxxx

    wglxxx

    Joined:
    Oct 27, 2018
    Posts:
    6
    Thank you so much.Here is my info:
    ML Agents Ver: ml-agents-release_1
    Unity Ver: 2019.3.2f1
    C# Ver: VStudio 2017 .net framework 4.8
    Python Ver: 3.6.5
    cuda(cudnn) Ver: 10
    config file: I followed the guide(Learning-Environment-Create-New.md) and trained RollerAgent.
    It works well, so I used the same file, only changed behavior name to 'Cha Behavior'.
     
  4. celion_unity

    celion_unity

    Joined:
    Jun 12, 2019
    Posts:
    289
    Agents are not stepped by default; you'll need to call Agent.RequestDecision() before calling Academy.Instance.EnvironmentStep() (or add a DecisionRequester) Monobehaviour