Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Bug Cannot make inference on neural network trained using ML-Agents

Discussion in 'ML-Agents' started by Cold85, Sep 22, 2021.

  1. Cold85

    Cold85

    Joined:
    Sep 22, 2021
    Posts:
    6
    Hi,

    I trained a neural network using ML-Agents. Training completely perfectly on PyTorch side, but when I tried to make inference using the .onnx created, Barracuda gives me a whole list of error.

    I have attached the onnx file in this question. Adding it into Editor already produces error (Cannot reshape array of size...). Running inference with the onnx file in game mode also produces error (Off-axis dimensions must match).

    My agent uses 2 Buffer Sensors, 1 Grid Sensor (with resnet and 6-channel input), and vector observations. Did some investigation and tried one version with Buffer Sensors only, one version with Grid Sensors only, both managed to run inferences with no errors. It's when they are combined that the error arises.

    Not sure if this is a Barracuda or ML-Agents (or both) problem. I posted a more detailed version of this question on Barracuda's forum.
    https://forum.unity.com/threads/can...ural-network-trained-using-ml-agents.1172924/

    I am using:
    ML-Agents Release 18 (uses Barracuda 2.0.0)
    PyTorch 1.7.1
    Unity Version 2019.4.1f1
    Windows 10 OS

    Urgently need experts' help on this.

    Thank you.
     

    Attached Files:

  2. WaxyMcRivers

    WaxyMcRivers

    Joined:
    May 9, 2016
    Posts:
    59
    Have you confirmed that you're using the same barracuda version in the package manager of unity?
     
  3. Cold85

    Cold85

    Joined:
    Sep 22, 2021
    Posts:
    6
    @WaxyMcRivers, I installed ML-Agents from the package manager. Below are screenshots of ML-Agents and Barracuda versioning from Unity package manager:

    Barracuda versioning.JPG ML-Agents Release 18 versioning.JPG

    Barracuda 2.0.0 is being used, this should be the correct version that ML-Agents release 18 uses according to the versioning page in ML-Agents Git Repo.
     
  4. WaxyMcRivers

    WaxyMcRivers

    Joined:
    May 9, 2016
    Posts:
    59
    I tried loading your onnx model into a project with different versions of barracuda. The version that worked for me is 2.1.0-preview
     
  5. Cold85

    Cold85

    Joined:
    Sep 22, 2021
    Posts:
    6
    @WaxyMcRivers Thank you for the info!

    I upgraded my project's Barracuda version to 2.1.0-preview. My quick test show that errors no longer appear when the onnx file is add to editor. Also, errors no longer appear when running inference in game mode. I'll test it more thoroughly for sure.

    If any creators of ML-Agents is looking at this thread, suggest that further releases be updated to use Barracuda 2.1.0.

    Thanks for all the help.
     
    WaxyMcRivers likes this.