浏览代码

Merge pull request #1453 from Unity-Technologies/release-v0.6-revertTF1-documentation

Documentation revert TF#
/develop-generalizationTraining-TrainerController
GitHub 6 年前
当前提交
6927cff8
共有 13 个文件被更改,包括 244 次插入49 次删除
  1. 19
      docs/Background-TensorFlow.md
  2. 38
      docs/Basic-Guide.md
  3. 14
      docs/FAQ.md
  4. 14
      docs/Getting-Started-with-Balance-Ball.md
  5. 10
      docs/Learning-Environment-Design-Learning-Brains.md
  6. 4
      docs/Learning-Environment-Executable.md
  7. 4
      docs/ML-Agents-Overview.md
  8. 12
      docs/Migrating.md
  9. 2
      docs/Readme.md
  10. 2
      docs/Training-Imitation-Learning.md
  11. 2
      docs/Training-ML-Agents.md
  12. 55
      docs/Using-TensorFlow-Sharp-in-Unity.md
  13. 117
      docs/images/imported-tensorflowsharp.png

19
docs/Background-TensorFlow.md


performing computations using data flow graphs, the underlying representation of
deep learning models. It facilitates training and inference on CPUs and GPUs in
a desktop, server, or mobile device. Within the ML-Agents toolkit, when you
train the behavior of an agent, the output is a TensorFlow model (.tf) file
train the behavior of an agent, the output is a TensorFlow model (.bytes) file
that you can then embed within a Learning Brain. Unless you implement a new
algorithm, the use of TensorFlow is mostly abstracted away and behind the
scenes.

recommend our guide on [using Tensorboard with ML-Agents](Using-Tensorboard.md) or
this [tutorial](https://github.com/dandelionmane/tf-dev-summit-tensorboard-tutorial).
## Tensorflow Model Inference
## TensorflowSharp
We have are using the [Unity Machine Learning Inference SDK](Inference-Engine.md) to
run the models inside of Unity. In order to use it, you will need to have an
appropriate backend downloaded.
This means that the Learning Brain is not natively supported since Unity scripts
are written in C#. Consequently, to enable the Learning Brain, we leverage a
third-party library
[TensorFlowSharp](https://github.com/migueldeicaza/TensorFlowSharp) which
provides .NET bindings to TensorFlow. Thus, when a Unity environment that
contains a Learning Brain is built, inference is performed via TensorFlowSharp.
We provide an additional in-depth overview of how to leverage
[TensorFlowSharp within Unity](Using-TensorFlow-Sharp-in-Unity.md)
which will become more
relevant once you install and start training behaviors within the ML-Agents
toolkit. Given the reliance on TensorFlowSharp, the Learning Brain is currently
marked as experimental.

38
docs/Basic-Guide.md


Equivalent or .NET 4.x Equivalent)**
6. Go to **File** > **Save Project**
## Setting up the Inference Engine
## Setting up TensorFlowSharp
We provide pre-trained models for all the agents in all our demo environments.
To be able to run those models, you'll first need to set-up the Inference
Engine. The Inference Engine is a general API to
run neural network models in Unity that leverages existing inference libraries such
as TensorFlowSharp and Apple's Core ML. Since the ML-Agents Toolkit uses TensorFlow
for training neural network models, the output model format is TensorFlow and
the model files include a `.tf` extension. Consequently, you need to install
the TensorFlowSharp backend to be able to run these models within the Unity
Editor. You can find instructions
on how to install the TensorFlowSharp backend [here](Inference-Engine.md).
Once the backend is installed, you will need to reimport the models : Right click
on the `.tf` model and select `Reimport`.
We provide pre-trained models (`.bytes` files) for all the agents
in all our demo environments. To be able to run those models, you'll
first need to set-up TensorFlowSharp support. Consequently, you need to install
the TensorFlowSharp plugin to be able to run these models within the Unity
Editor.
1. Download the [TensorFlowSharp Plugin](https://s3.amazonaws.com/unity-ml-agents/0.5/TFSharpPlugin.unitypackage)
2. Import it into Unity by double clicking the downloaded file. You can check
if it was successfully imported by checking the
TensorFlow files in the Project window under **Assets** > **ML-Agents** >
**Plugins** > **Computer**.
3. Go to **Edit** > **Project Settings** > **Player** 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`**).
![Project Settings](images/project-settings.png)
**Note**: If you don't see anything under **Assets**, drag the
`UnitySDK/Assets/ML-Agents` folder under **Assets** within Project window.
![Imported TensorFlowsharp](images/imported-tensorflowsharp.png)
## Running a Pre-trained Model

### After training
You can press Ctrl+C to stop the training, and your trained model will be at
`models/<run-identifier>/<brain_name>.tf` where
`models/<run-identifier>/<brain_name>.bytes` where
`<brain_name>` is the name of the Brain corresponding to the model.
(**Note:** There is a known bug on Windows that causes the saving of the model to
fail when you early terminate the training, it's recommended to wait until Step

`UnitySDK/Assets/ML-Agents/Examples/3DBall/TFModels/`.
2. Open the Unity Editor, and select the **3DBall** scene as described above.
3. Select the **3DBallLearning** Learning Brain from the Scene hierarchy.
5. Drag the `<brain_name>.tf` file from the Project window of
5. Drag the `<brain_name>.bytes` file from the Project window of
the Editor to the **Model** placeholder in the **3DBallLearning**
inspector window.
6. Press the :arrow_forward: button at the top of the Editor.

14
docs/FAQ.md


to [Setting Up The ML-Agents Toolkit Within
Unity](Installation.md#setting-up-ml-agent-within-unity) for solution.
## Cannot drag Model into Learning Brain
## TensorFlowSharp flag not turned on
You might not have the appropriate backend required to import the model. Refer to the
[Inference Engine](Inference-Engine.md) for more information on how to import backends
and reimport the asset.
If you have already imported the TensorFlowSharp plugin, but haven't set
ENABLE_TENSORFLOW flag for your scripting define symbols, you will see the
following error message:
```console
UnityAgentsException: The brain 3DBallLearning was set to inference mode but the Tensorflow library is not present in the Unity project.
```
This error message occurs because the TensorFlowSharp plugin won't be used
without the ENABLE_TENSORFLOW flag, refer to [Setting Up The ML-Agents Toolkit
Within Unity](Installation.md#setting-up-ml-agent-within-unity) for solution.
## Environment Permission Error

14
docs/Getting-Started-with-Balance-Ball.md


use it with Agents having a **Learning Brain**.
__Note:__ Do not just close the Unity Window once the `Saved Model` message appears.
Either wait for the training process to close the window or press Ctrl+C at the
command-line prompt. If you simply close the window manually, the `.tf` file
command-line prompt. If you close the window manually, the `.bytes` file
### Setting up Inference Support
### Setting up TensorFlowSharp
In order to run neural network models inside of Unity, you will need to setup the
Inference Engine with an appropriate backend. See [here](Inference-Engine.md) for more
information.
Because TensorFlowSharp support is still experimental, it is disabled by
default. Please note that the `Learning` Brain inference can only be used with
TensorFlowSharp.
To set up the TensorFlowSharp Support, follow [Setting up ML-Agents Toolkit
within Unity](Basic-Guide.md#setting-up-ml-agents-within-unity) section. of the
Basic Guide page.
### Embedding the trained model into Unity

10
docs/Learning-Environment-Design-Learning-Brains.md


To use a graph model:
1. Select the **Learning Brain** asset in the **Project** window of the Unity Editor.
**Note:** In order to use the **Learning** Brain, you have appropriate backend for the
Inference Engine. See [here](Inference-Engine.md).
**Note:** In order to use the **Learning** Brain with inference, you need to have
TensorFlowSharp enabled. Refer to [this section](Basic-Guide.md#setting-up-ml-agents-within-unity) for more information.
2. Import the `model_name` file produced by the PPO training
program. (Where `model_name` is the name of the model file, which is
constructed from the name of your Unity environment executable and the run-id

[import assets into Unity](https://docs.unity3d.com/Manual/ImportingAssets.html)
in various ways. The easiest way is to simply drag the file into the
**Project** window and drop it into an appropriate folder.
3. Once the `model_name.tf` file is imported, drag it from the **Project**
3. Once the `model_name.bytes` file is imported, drag it from the **Project**
window to the **Model** field of the Brain component.
If you are using a model produced by the ML-Agents `mlagents-learn` command, use

The default values of the TensorFlow graph parameters work with the model
produced by the PPO and BC training code in the ML-Agents SDK. To use a default
ML-Agents model, the only parameter that you need to set is the `Model`,
which must be set to the `.tf` file containing the trained model itself.
which must be set to the `.bytes` file containing the trained model itself.
* `Model` : This must be the `.tf` file corresponding to the pre-trained
* `Model` : This must be the `.bytes` file corresponding to the pre-trained
TensorFlow graph. (You must first drag this file into your Project window
and then from the Resources folder into the inspector)

4
docs/Learning-Environment-Executable.md


```
You can press Ctrl+C to stop the training, and your trained model will be at
`models/<run-identifier>/<brain_name>.tf`, which corresponds
`models/<run-identifier>/<brain_name>.bytes`, which corresponds
to your model's latest checkpoint. (**Note:** There is a known bug on Windows
that causes the saving of the model to fail when you early terminate the
training, it's recommended to wait until Step has reached the max_steps

`UnitySDK/Assets/ML-Agents/Examples/3DBall/TFModels/`.
2. Open the Unity Editor, and select the **3DBall** scene as described above.
3. Select the **Ball3DLearning** object from the Project window.
5. Drag the `<brain_name>.tf` file from the Project window of
5. Drag the `<brain_name>.bytes` file from the Project window of
the Editor to the **Model** placeholder in the **Ball3DLearning**
inspector window.
6. Remove the **Ball3DLearning** from the Academy's `Broadcast Hub`

4
docs/ML-Agents-Overview.md


model. This model is then embedded within the Learning Brain during inference to
generate the optimal actions for all Agents linked to that Brain.
**Note that our Learning Brain is currently experimental as it is limited to TensorFlow
models and leverages the third-party
[TensorFlowSharp](https://github.com/migueldeicaza/TensorFlowSharp) library.**
The
[Getting Started with the 3D Balance Ball Example](Getting-Started-with-Balance-Ball.md)
tutorial covers this training mode with the **3D Balance Ball** sample environment.

12
docs/Migrating.md


* When training multiple Brains at the same time, each model is now stored
into a separate model file rather than in the same file under different
graph scopes.
* We have changed the way ML-Agents models perform inference. All previous `.bytes`
files can no longer be used (you will have to retrain them). The models
produced by the training process and the shipped models have now a `.tf`
extension and use TensorflowSharp as a backend for the
[Inference Engine](Inference-Engine.md).
* To use a `.tf` model, drag it inside the `Model` property of the `Learning Brain`
* The **Learning Brain** graph scope, placeholder names, output names and custom
placeholders can no longer be modified.
#### Steps to Migrate

from the `mlagents-learn` Python script, you need to drag the relevant
`LearningBrain` ScriptableObjects used in your scene into entries
into this list.
* You will need to delete the previous TensorFlowSharp package
and install the new one to do inference. To correctly delete the previous
TensorFlowSharp package, Delete all of the files under `ML-Agents/Plugins`
folder except the files under `ML-Agents/Plugins/ProtoBuffer`.
## Migrating from ML-Agents toolkit v0.4 to v0.5

2
docs/Readme.md


* [Using TensorBoard to Observe Training](Using-Tensorboard.md)
## Inference
* [Unity Machine Learning Inference SDK](Inference-Engine.md)
* [TensorFlowSharp in Unity (Experimental)](Using-TensorFlow-Sharp-in-Unity.md)
## Help

2
docs/Training-Imitation-Learning.md


similarly to the demonstrations.
9. Once the Student Agents are exhibiting the desired behavior, end the training
process with `CTL+C` from the command line.
10. Move the resulting `*.tf` file into the `TFModels` subdirectory of the
10. Move the resulting `*.bytes` file into the `TFModels` subdirectory of the
Assets folder (or a subdirectory within Assets of your choosing) , and use
with `Learning` Brain.

2
docs/Training-ML-Agents.md


When training is finished, you can find the saved model in the `models` folder
under the assigned run-id — in the cats example, the path to the model would be
`models/cob_1/CatsOnBicycles_cob_1.tf`.
`models/cob_1/CatsOnBicycles_cob_1.bytes`.
While this example used the default training hyperparameters, you can edit the
[training_config.yaml file](#training-config-file) with a text editor to set

55
docs/Using-TensorFlow-Sharp-in-Unity.md


# Using TensorFlowSharp in Unity (Experimental)
The ML-Agents toolkit allows you to use pre-trained
[TensorFlow graphs](https://www.tensorflow.org/programmers_guide/graphs)
inside your Unity
games. This support is possible thanks to the
[TensorFlowSharp project](https://github.com/migueldeicaza/TensorFlowSharp).
The primary purpose for this support is to use the TensorFlow models produced by
the ML-Agents toolkit's own training programs, but a side benefit is that you
can use any TensorFlow model.
_Notice: This feature is still experimental. While it is possible to embed
trained models into Unity games, Unity Technologies does not officially support
this use-case for production games at this time. As such, no guarantees are
provided regarding the quality of experience. If you encounter issues regarding
battery life, or general performance (especially on mobile), please let us
know._
## Supported devices
* Linux 64 bits
* Mac OS X 64 bits
* Windows 64 bits
* iOS (Requires additional steps)
* Android
## Requirements
* Unity 2017.4 or above
* Unity TensorFlow Plugin ([Download here](https://s3.amazonaws.com/unity-ml-agents/0.5/TFSharpPlugin.unitypackage))
## Using TensorFlowSharp with ML-Agents
Go to `Edit` -> `Player Settings` 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`**).
Set the Brain you used for training to `Learning`. Drag `your_name_graph.bytes`
into Unity and then drag it into The `Model` field in the Brain.
## iOS additional instructions for building
* Before build your game against iOS platform, make sure you've set the
flag `ENABLE_TENSORFLOW` for it.
* Once you build the project for iOS in the editor, open the .xcodeproj file
within the project folder using Xcode.
* Set up your ios account following the
[iOS Account setup page](https://docs.unity3d.com/Manual/iphone-accountsetup.html).
* In **Build Settings** > **Linking** > **Other Linker Flags**:
* Double click on the flag list to expand the list
* Add `-force_load`
* Drag the library `libtensorflow-core.a` from the **Project Navigator** on
the left under `Libraries/ML-Agents/Plugins/iOS` into the flag list, after
`-force_load`.

117
docs/images/imported-tensorflowsharp.png

之前 之后
宽度: 452  |  高度: 288  |  大小: 27 KiB
正在加载...
取消
保存