ml-agent: environment installation under Win10

This is the most comprehensive and detailed ml-agent explanation I have seen. (Only used for learning and knowledge sharing, if there is any infringement, please contact to delete. Thank you!)

From CodeGize's personal blog . Source link: https://www.cnblogs.com/CodeGize/p/7674281.html#undefined

 

Supplement of personal knowledge: (If there is a hint that the pip version is low during installation, please follow the steps below to solve it. If there is no error, you can ignore it)

  In the " input command to install Tensorflow input  pip install -U tensorflow " step, if your pip version is not the latest, an error will be reported, there is no way it must be the latest version.

  Go to the pip official website to download the latest version and extract it to a custom directory. From the start menu, open Anacoda Prompt and enter the unzipped pip-10.0.1 (the version I use) directory.

  (The same disk directory can be directly cd to the directory where it is located; if it is not the same disk, C: or D: (the disk where it is located) is cd after entering the disk).

  After entering the directory, enter the python setup.py install command to install. After installation, continue to install Tensorflow.

Enter the text:

Introduction

        AI artificial intelligence, more precisely machine learning (machine learning) has been very hot in recent years. In the recent past, Unity also released a machine learning tool called ml-agent.

        The English introduction is as follows:

  https://blogs.unity3d.com/cn/2017/09/19/introducing-unity-machine-learning-agents/

        The Chinese introduction is as follows:

  http://forum.china.unity3d.com/thread-27837-1-1.html

        The address of the project on Github is as follows

  https://github.com/Unity-Technologies/ml-agents

        In terms of code structure, ml-agent implements a system in which the front end uses Unity for performance, and the back end uses Phython for artificial intelligence calculation.

build environment

main environment

The official recommended environment is as follows

  • Phython2 / 3 64th
  • jupyter notebook
  • TensorFlow (1.0+) (Training)
  • Visual Studio 2017
  • Unity3d 2017

Long ml-agent code base

        Clone (download) ml-agent, code from Github website and put it under any location.

Install Unity2017.2

        Download Unity2017.2 from the Unity official website and install it.

        Download addresshttps: //store.unity.com/cn/download?ref=personal

Install VS2017

        Download it from the Microsoft official website https://www.visualstudio.com/zh-hans/downloads/ , and select the required module after running it. Although there are related plugins for python, we choose to install them separately later.

Install Anaconda

        Install Anaconda5.0.0 from the Anaconda official website

2017101501

        Download address https://www.anaconda.com/download/#windows

        After installation, open Anaconda Navigator from the start menu and select Environments on the left. Click Create in the menu below to create an environment, name it tensorflow, and select the python version as 3.6. Wait for the environment creation to complete.

2017101502

Install Tensorflow and its dependencies

        From the start menu, open Anacoda Prompt.

        First activate the environment you just created and enter the command

  activate tensorflow

2017101503

        Enter the command to install Tensorflow

  pip install –U tensorflow

        Wait for a while until the installation is complete. This completes the installation of the latest version of Tensorflow. (currently version 1.3.0)

        You have to enter commands later, so don't close the window for now

Install ml-agent dependency library

        After completing the Tensorflow installation, continue to enter the command in Anacoda Prompt to switch to the location of the python directory in the directory where ml-agent is located. For example, if the ml-agent installation directory is D:\Git\ml-agent, enter

cd D:\Git\ml-agent\python

        If your Anaconda is not installed on the same disk as the ml-agent directory, you need to switch to the disk where ml-agen is located. For example, the installation directory of Anaconda here is C drive, and the ml-agent installation directory is D:\ml-agent, you need to switch to D drive, enter

D:

        Then start to install the environment required for Demo, enter the command

pip install .

        Be careful not to miss the last dot. Wait for the installation to complete. Do not close this window at this time

run

Compile the Unity program

        Unity's ml-agent provides a good demo. Here try to run the 3dball demo.

        Use Unity2017 to open the unity-environment folder under ml-agent.

        Open the scene file in the Assets\ML-Agents\Examples\3DBall directory. Select the Ball3DBrain object under Ball3DAcademy in the scene, and change the TypeOfBrain to External, which means to obtain data from Tensorflow.

2017101504

        Select File->Build Setting in the menu to add the current scene. (You can check Development Build to see the output)

        Click on PlayerSeting to check the settings

        Resolution and Presentation -> 勾选Run in Background

        Resolution and Presentation -> Display Resolution Dialog set to disable

        Go back to the Build Setting panel, click Build, and compile it into the python directory of ml-agent. named 3dball.exe

2017101505

Run Jupyter Notebook

        Go back to the Anacoda Prompt command window. Note that you must switch to the directory where python is located in ml-agent. enter

jupyter notebook

        After running, on the one hand, a command line window will appear, and on the other hand, a web page will be opened at the same time

2017101506

2017101507

        Click on PPO.ipynb in the web page. Modify the value of env_name to the name of the exe just compiled. Be careful not to add exe. Then select Cell->RunAll on the menu

2017101508

        After running, you can see that the exe just compiled is running

2017101509

Summarize

        Note a few points

  • Although many articles show that tensorflow is better with python3.5, there is no in-depth study of what the impact is.
  • Since Anaconda uses version 5.0.0, the default version is python3.6. In this case, if you create a python3.5 environment and install tensorflow1.2, there will be a problem that tensorflow cannot be found when running. And if you use the python3.6 environment, but install tensorflow1.2, there will be a problem that tensorflow.TensorLayer cannot be found. These problems took a lot of time to investigate and need attention, so in the end, Anaconda5.0.0, python3.6 and tensorflow1.3 were used here
  • When installing dependent libraries, you need to pay attention, and you must switch the environment. Otherwise, it is likely to be installed in a different environment. Before installing here, you must enter the activate tensorflow command (tensorflow is the name of the environment I created)

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324818571&siteId=291194637