Search Unity

  1. Unity 2020.1 has been released.
    Dismiss Notice
  2. We are looking for feedback on the experimental Unity Safe Mode which is aiming to help you resolve compilation errors faster during project startup.
    Dismiss Notice
  3. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

Syntax error: can't assign to operator when training with executable

Discussion in 'ML-Agents' started by KNRichardson, Jul 31, 2020.

  1. KNRichardson

    KNRichardson

    Joined:
    Jul 20, 2020
    Posts:
    5
    Hi, any idea why I'm getting this syntax error when I try to initiate training on a build from the terminal?

    >>> mlagents-learn /config/ppo/Basic.yaml --env=basictest --run-id=firstRun
    File "<stdin>", line 1
    SyntaxError: can't assign to operator


    I am running the command from the root of the project directory (master-ml-agents if you like), which is where all the cloned directories are (ml-agents, ml-agents-envs etc) including the config folder and including the executable, named basictest.x86_64, and the associated data folder.

    Before this command I'd ran
    python
    >>> from mlagents_envs.environment import UnityEnvironment
    >>> env = UnityEnvironment(file_name='basictest.x86_64')
    >>> env.reset()

    and that works in terms of producing a pop up window showing the basic environment.

    I am on Linux Ubuntu 18.04, Unity 2019.4.4f1. I created a pipenv with Python 3.6, cloned the ML-Agents repo and did pip install -e for ml-agents, ml-agents-envs and gym-unity (all 0.18.0 and tensorflow 2.2.0 was installed as dependency).

    I've tried using the full file path to the build from home drive instead of just build name. I've tried 'Basic' instead of 'basictest'. I've looked at the migration document outlining the config format changes and tried the script upgrade_config.py but it returns an identical yaml file so I think the format I have is up to date. I've tried taking the first line 'behavior:' out of Basic.yaml. Can't figure it out.
     
  2. celion_unity

    celion_unity

    Unity Technologies

    Joined:
    Jun 12, 2019
    Posts:
    187
    Hi,
    mlagents-learn is a console script that gets created when you install the pip package. It looks like you're trying to run it from the python interpreter, which isn't working because that's not valid python code.

    mlagents-learn is meant to be run from the command line, but if you really really want to run it from the interpreter, the equivalent to what you're trying to do would be

    Code (CSharp):
    1. >>> from mlagents.trainers.learn import run_cli, parse_command_line
    2. >>> run_cli(parse_command_line(["/config/ppo/Basic.yaml", "--env=basictest", "--run-id=firstRun"])
    Which is what happens when learn.py is run as the main method here.

    Also note that you probably want
    ./config/ppo/Basic.yaml
    (leading
    .
    )
     
  3. KNRichardson

    KNRichardson

    Joined:
    Jul 20, 2020
    Posts:
    5
    Hi,

    Yep, very obvious now you point it out. Thanks a lot!
     
unityunity