Tutorials

Where to Start?

The biggest question I had once I found about using ML with Unity was where I could actually start. While there is a github repo that is constantly updated (https://github.com/Unity-Technologies/ml-agents) , the documentation included was not (for me at least) the most understandable in how to actually get the thing up and running.

THankfully, though I missed the live demo at GDC, Unity have provided it in a playlist format for everyone on YouTube: https://www.youtube.com/watch?v=32wtJZ3yRfw&list=PLX2vGYjWbI0R08eWQkO7nQkGiicHAX7IX&index=0

I’d recommend downloading the project from github, and then going along with the video to better understand how to use the ML agents, and get an understanding of the two types of ML that are available (It’s worth noting that while the guide mentions both Reinforcement Learning and Imitation Learning in order to explain the differences between the two, the tutorial itself focuses on Reinforcement Learning.

I’ll also note a few issues I encountered while following along:

  1. My Python 3 install was not present in my Windows path, so I had to manually add it. If you are installing Python 3 from the website, this option is provided during the install process. Unless you plan to run multiple versions of Python on your system, I’d recommend ticking that option.
  2. Several packages were not installed or listed as dependencies, so when I started up the learn.py section, Python wouldnt run until these had been installed. Using PIP (on Windows this is called with Python -m pip <package name> from command prompt), make sure you have the following:
    • docopt
    • numpy
    • image
    • tensorflow==1.4.*
    • PyYAML
  3. It is important to note the use of Tensorflow 1.4, as by default PIP installed 1.8, which currently has issues with TF#, and if you build your Tensorflow data with 1.8, when you fix it and install 1.4, you have to re-run your training simulation again to rebuild a new .byte file that is compatible.
  4. You’ll need to have installed Tensorflow # (sharp) plugin for Unity, see the guide here for full details. The short version is basically download and import this Unity package, then go to Go to Edit -> Player Settings and set  the Scripting Runtime Version under Configuration to Experimental (.NET 4.6 or equivalent) and  add ENABLE_TENSORFLOW to the Scripting Define Symbols for each type of device you want to use (PC, Mac and Linux Standalone, iOS or Android). Once all that is done, save, close and then re-open Unity.

Other than those minor hiccups, I was able to get everything working.