Search Unity

Question How do I stop my agent moving really fast during inference?

Discussion in 'ML-Agents' started by StewedHarry, Aug 27, 2020.

  1. StewedHarry

    StewedHarry

    Joined:
    Jan 20, 2020
    Posts:
    45
    My agent seems to move extremely fast during inference. I think may have something to do with the frames per second during inference - 60-90fps. I train at around 7-11fps and the movement seems slower than it should be. Am I making a generic Unity scripting error or is this tied to the ML agent toolkit?

    The code that moves my agent is:

    Code (CSharp):
    1. AgentRigidbody.MovePosition(transform.position + movementDirection * Time.fixedDeltaTime * Speed);
     
  2. Hsgngr

    Hsgngr

    Joined:
    Dec 28, 2015
    Posts:
    61
    The simulation runs x20 during training. You can change it from Player Settings> Time > TimeScale Maybe this is the case
     
    SilkySeal likes this.
  3. StewedHarry

    StewedHarry

    Joined:
    Jan 20, 2020
    Posts:
    45
    This is occurring during inference, which is why I'm confused. I thought inference was supposed to run at normal time. Where do I find Player Settings?
     
  4. Hsgngr

    Hsgngr

    Joined:
    Dec 28, 2015
    Posts:
    61
    Edit > Project Settings. If its the case maybe you should decrease the "Speed" constant coeff in your MovePosition() function
     
    Last edited: Aug 27, 2020
  5. Luke-Houlihan

    Luke-Houlihan

    Joined:
    Jun 26, 2007
    Posts:
    303
    Are you using the same control code during both training and inference? Any changes after training will give strange results.

    Also you may be experiencing a 'studder-step' problem where your training fps is so low it makes the agent look slower than it really is in the physics step. Try running your training at normal speed using either the project settings as @Hsgngr advised or using the --time-scale=1 if you do training from a standalone (the default timescale for training is 20)
     
  6. StewedHarry

    StewedHarry

    Joined:
    Jan 20, 2020
    Posts:
    45
    I'm using the same control code for training and inference. I imagine I am experience studder-step, but I didn't anticipate such a large variation. I'll try running the project in normal speed next time I'm running inference
     
    Luke-Houlihan likes this.
  7. StewedHarry

    StewedHarry

    Joined:
    Jan 20, 2020
    Posts:
    45
    This worked. Thanks! Timescale was set at 20 during inference for some reason
     
    Hsgngr likes this.