Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

How to create onnx??

Discussion in 'ML-Agents' started by Airmouse, Aug 27, 2022.

  1. Airmouse


    Jan 12, 2019
    Hi, I have now been trying for over 5 days to install Tensorflow 2.9, Keras, Pytorch and tf2onnx. but am completely unable to crete a working onnx for Unity,

    I created a simple model in Keras then used tf2onnx to create a onnx model.

    I then added it to the Unity project and created a new Agent controller,

    placed the onnx in the model field and it always says required constant VERSION_NUMBER missing.


    if I bypass version number requirement:
    Code (CSharp):
    1. public static int GetVersion(this Model model)
    2. {
    3.     return 2;//(int)model.GetTensorByName(TensorNames.VersionNumber)[0];
    4. }
    then I get new error:
    UnityAgentsException: Models from 1.x that use recurrent neural networks are not supported in newer versions. Either retrain with an newer trainer, or use an older version of

    I am trying to learn what is the simplest way to create a onnx that works in Unity and am so far unsuccessful at ever attept. I have no idea what to do now. There are no tutorials I can find anywhere and documentation seems to be from many years ago.

    can someone please help me to create a working onnx that Unity can understand?

    Here is the onnx model file:
    Here is the Python code:

    Is Keras even supported?? Or do I have to use torch??
    Last edited: Aug 27, 2022