Skip to content

Commit ab0962e

Browse files
author
Marwan Mattar
authored
Several, small documentation improvements (#3903)
* Several, small documentation improvements - Re-organize main repo README - Minor clean-ups to Python package-specific readme files - Clean-up to Unity Inference Engine page - Update to the docs README - Added a specific cross-platform section in ML-Agents Overview to amplify Barracuda - Updated the links in Limitations.md to point to the specific subsections - Cleaned up the Designing a Learning Environment page. Added an intro paragraph. - Updated the installation guide to specifically call out local installation - A few minor formatting, spelling errors fixed.
1 parent 2548035 commit ab0962e

18 files changed

+617
-472
lines changed

README.md

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
<img src="docs/images/image-banner.png" align="middle" width="3000"/>
44

55
# Unity ML-Agents Toolkit (Beta)
6+
67
[![docs badge](https://img.shields.io/badge/docs-reference-blue.svg)](https://github.com/Unity-Technologies/ml-agents/tree/release_1_docs/docs/)
78

89
[![license badge](https://img.shields.io/badge/license-Apache--2.0-green.svg)](LICENSE)
@@ -27,20 +28,25 @@ developer communities.
2728

2829
## Features
2930

30-
- Unity environment control from Python
31-
- 15+ sample Unity environments
32-
- Two deep reinforcement learning algorithms, Proximal Policy Optimization (PPO)
33-
and Soft Actor-Critic (SAC)
31+
- 15+ [example Unity environments](docs/Learning-Environment-Examples.md)
3432
- Support for multiple environment configurations and training scenarios
35-
- Self-play mechanism for training agents in adversarial scenarios
36-
- Train memory-enhanced agents using deep reinforcement learning
37-
- Easily definable Curriculum Learning and Generalization scenarios
33+
- Flexible Unity SDK that can be integrated into your game or custom Unity scene
34+
- Training using two deep reinforcement learning algorithms, Proximal Policy
35+
Optimization (PPO) and Soft Actor-Critic (SAC)
3836
- Built-in support for Imitation Learning through Behavioral Cloning or
3937
Generative Adversarial Imitation Learning
38+
- Self-play mechanism for training agents in adversarial scenarios
39+
- Easily definable Curriculum Learning scenarios for complex tasks
40+
- Train robust agents using environment randomization
4041
- Flexible agent control with On Demand Decision Making
41-
- Wrap learning environments as a gym
42-
- Utilizes the Unity Inference Engine
43-
- Train using concurrent Unity environment instances
42+
- Train using multiple concurrent Unity environment instances
43+
- Utilizes the [Unity Inference Engine](docs/Unity-Inference-Engine.md) to
44+
provide native cross-platform support
45+
- Unity environment [control from Python](docs/Python-API.md)
46+
- Wrap Unity learning environments as a [gym](gym-unity/README.md)
47+
48+
See our [ML-Agents Overview](docs/ML-Agents-Overview.md) page for detailed
49+
descriptions of all these features.
4450

4551
## Releases & Documentation
4652

Lines changed: 75 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -1,79 +1,88 @@
11
# About ML-Agents package (`com.unity.ml-agents`)
22

3-
The Unity ML-Agents package contains the C# SDK for the [Unity ML-Agents Toolkit].
4-
5-
The package allows you to convert any Unity scene to into a learning
6-
environment and train character behaviors using a variety of machine learning
7-
algorithms. Additionally, it allows you to embed these trained behaviors back into
8-
Unity scenes to control your characters. More specifically, the package provides
9-
the following core functionalities:
10-
11-
* Define Agents: entities, or characters, whose behavior will be learned. Agents are entities
12-
that generate observations (through sensors), take actions, and receive rewards from
13-
the environment.
14-
* Define Behaviors: entities that specifiy how an agent should act. Multiple agents can
15-
share the same Behavior and a scene may have multiple Behaviors.
16-
* Record demonstrations of an agent within the Editor. You can use demonstrations
17-
to help train a behavior for that agent.
18-
* Embedding a trained behavior into the scene via the [Unity Inference Engine].
19-
Embedded behaviors allow you to switch an Agent between learning and inference.
20-
21-
Note that the *ML-Agents* package does not contain the machine learning algorithms for training
22-
behaviors. The *ML-Agents* package only supports instrumenting a Unity scene, setting it up for
23-
training, and then embedding the trained model back into your Unity scene. The machine learning
24-
algorithms that orchestrate training are part of the companion [Python package].
25-
3+
The Unity ML-Agents package contains the C# SDK for the [Unity ML-Agents
4+
Toolkit].
5+
6+
The package allows you to convert any Unity scene to into a learning environment
7+
and train character behaviors using a variety of machine learning algorithms.
8+
Additionally, it allows you to embed these trained behaviors back into Unity
9+
scenes to control your characters. More specifically, the package provides the
10+
following core functionalities:
11+
12+
- Define Agents: entities, or characters, whose behavior will be learned. Agents
13+
are entities that generate observations (through sensors), take actions, and
14+
receive rewards from the environment.
15+
- Define Behaviors: entities that specifiy how an agent should act. Multiple
16+
agents can share the same Behavior and a scene may have multiple Behaviors.
17+
- Record demonstrations of an agent within the Editor. You can use
18+
demonstrations to help train a behavior for that agent.
19+
- Embedding a trained behavior into the scene via the [Unity Inference Engine].
20+
Embedded behaviors allow you to switch an Agent between learning and
21+
inference.
22+
23+
Note that the _ML-Agents_ package does not contain the machine learning
24+
algorithms for training behaviors. The _ML-Agents_ package only supports
25+
instrumenting a Unity scene, setting it up for training, and then embedding the
26+
trained model back into your Unity scene. The machine learning algorithms that
27+
orchestrate training are part of the companion [Python package].
2628

2729
## Package contents
2830

2931
The following table describes the package folder structure:
3032

31-
|**Location**|**Description**|
32-
|---|---|
33-
|*Documentation~*|Contains the documentation for the Unity package.|
34-
|*Editor*|Contains utilities for Editor windows and drawers.|
35-
|*Plugins*|Contains third-party DLLs.|
36-
|*Runtime*|Contains core C# APIs for integrating ML-Agents into your Unity scene. |
37-
|*Tests*|Contains the unit tests for the package.|
38-
33+
| **Location** | **Description** |
34+
| ---------------- | ---------------------------------------------------------------------- |
35+
| _Documentation~_ | Contains the documentation for the Unity package. |
36+
| _Editor_ | Contains utilities for Editor windows and drawers. |
37+
| _Plugins_ | Contains third-party DLLs. |
38+
| _Runtime_ | Contains core C# APIs for integrating ML-Agents into your Unity scene. |
39+
| _Tests_ | Contains the unit tests for the package. |
3940

4041
<a name="Installation"></a>
42+
4143
## Installation
4244

43-
To install this *ML-Agents* package, follow the instructions in the [Package Manager documentation].
45+
To install this _ML-Agents_ package, follow the instructions in the [Package
46+
Manager documentation].
4447

4548
To install the companion Python package to enable training behaviors, follow the
4649
[installation instructions] on our [GitHub repository].
4750

48-
4951
## Requirements
5052

51-
This version of the Unity ML-Agents package is compatible with the following versions of the
52-
Unity Editor:
53+
This version of the Unity ML-Agents package is compatible with the following
54+
versions of the Unity Editor:
5355

54-
* 2018.4 and later
56+
- 2018.4 and later
5557

56-
57-
## Known limitations
58+
## Known Limitations
5859

5960
### Training
60-
Training is limited to the Unity Editor and Standalone builds on Windows, MacOS, and Linux with the
61-
Mono scripting backend. Currently, training does not work with the IL2CPP scripting backend. Your
62-
environment will default to inference mode if training is not supported or is not currently running.
61+
62+
Training is limited to the Unity Editor and Standalone builds on Windows, MacOS,
63+
and Linux with the Mono scripting backend. Currently, training does not work
64+
with the IL2CPP scripting backend. Your environment will default to inference
65+
mode if training is not supported or is not currently running.
6366

6467
### Inference
65-
Inference is executed via the [Unity Inference Engine](https://docs.unity3d.com/Packages/com.unity.barracuda@latest/index.html).
68+
69+
Inference is executed via the
70+
[Unity Inference Engine](https://docs.unity3d.com/Packages/com.unity.barracuda@latest/index.html).
6671

6772
**CPU**
68-
- All platforms supported.
73+
74+
All platforms supported.
6975

7076
**GPU**
71-
- All platforms supported except:
72-
- WebGL and GLES 3/2 on Android / iPhone
7377

74-
**NOTE:** Mobile platform support includes:
75-
- Vulkan for Android
76-
- Metal for iOS.
78+
All platforms supported except:
79+
80+
- WebGL and GLES 3/2 on Android / iPhone
81+
82+
**NOTE:** Mobile platform support includes:
83+
84+
- Vulkan for Android
85+
- Metal for iOS.
7786

7887
### Headless Mode
7988

@@ -92,24 +101,27 @@ You can control the frequency of Academy stepping by calling
92101
`Academy.Instance.EnvironmentStep()`
93102

94103
### Unity Inference Engine Models
104+
95105
Currently, only models created with our trainers are supported for running
96106
ML-Agents with a neural network behavior.
97107

98-
99108
## Helpful links
100109

101110
If you are new to the Unity ML-Agents package, or have a question after reading
102-
the documentation, you can checkout our
103-
[GitHUb Repository], which also includes a number of ways to [connect with us]
104-
including our [ML-Agents Forum].
105-
106-
107-
[Unity ML-Agents Toolkit]: https://github.com/Unity-Technologies/ml-agents
108-
[Unity Inference Engine]: https://docs.unity3d.com/Packages/com.unity.barracuda@latest/index.html
109-
[Package Manager documentation]: https://docs.unity3d.com/Manual/upm-ui-install.html
110-
[installation instructions]: https://github.com/Unity-Technologies/ml-agents/blob/release_1_docs/docs/Installation.md
111-
[GitHUb Repository]: https://github.com/Unity-Technologies/ml-agents
112-
[Python package]: https://github.com/Unity-Technologies/ml-agents
113-
[Execution Order of Event Functions]: https://docs.unity3d.com/Manual/ExecutionOrder.html
114-
[connect with us]: https://github.com/Unity-Technologies/ml-agents#community-and-feedback
115-
[ML-Agents Forum]: https://forum.unity.com/forums/ml-agents.453/
111+
the documentation, you can checkout our [GitHUb Repository], which also includes
112+
a number of ways to [connect with us] including our [ML-Agents Forum].
113+
114+
[unity ML-Agents Toolkit]: https://github.com/Unity-Technologies/ml-agents
115+
[unity inference engine]:
116+
https://docs.unity3d.com/Packages/com.unity.barracuda@latest/index.html
117+
[package manager documentation]:
118+
https://docs.unity3d.com/Manual/upm-ui-install.html
119+
[installation instructions]:
120+
https://github.com/Unity-Technologies/ml-agents/blob/release_1_docs/docs/Installation.md
121+
[github repository]: https://github.com/Unity-Technologies/ml-agents
122+
[python package]: https://github.com/Unity-Technologies/ml-agents
123+
[execution order of event functions]:
124+
https://docs.unity3d.com/Manual/ExecutionOrder.html
125+
[connect with us]:
126+
https://github.com/Unity-Technologies/ml-agents#community-and-feedback
127+
[ml-agents forum]: https://forum.unity.com/forums/ml-agents.453/

docs/Background-TensorFlow.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ that we leverage within the ML-Agents Toolkit.
1414
performing computations using data flow graphs, the underlying representation of
1515
deep learning models. It facilitates training and inference on CPUs and GPUs in
1616
a desktop, server, or mobile device. Within the ML-Agents Toolkit, when you
17-
train the behavior of an agent, the output is a TensorFlow model (.nn) file that
18-
you can then associate with an Agent. Unless you implement a new algorithm, the
19-
use of TensorFlow is mostly abstracted away and behind the scenes.
17+
train the behavior of an agent, the output is a model (.nn) file that you can
18+
then associate with an Agent. Unless you implement a new algorithm, the use of
19+
TensorFlow is mostly abstracted away and behind the scenes.
2020

2121
## TensorBoard
2222

docs/Custom-SideChannels.md

Lines changed: 52 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -8,58 +8,70 @@ inappropriate as an agent observation.
88

99
## Overview
1010

11-
In order to use a side channel, it must be implemented as both Unity and Python classes.
11+
In order to use a side channel, it must be implemented as both Unity and Python
12+
classes.
1213

1314
### Unity side
14-
The side channel will have to implement the `SideChannel` abstract class and the following method.
1515

16-
* `OnMessageReceived(IncomingMessage msg)` : You must implement this method and read the data from IncomingMessage.
17-
The data must be read in the order that it was written.
16+
The side channel will have to implement the `SideChannel` abstract class and the
17+
following method.
1818

19-
The side channel must also assign a `ChannelId` property in the constructor. The `ChannelId` is a Guid
20-
(or UUID in Python) used to uniquely identify a side channel. This Guid must be the same on C# and Python.
21-
There can only be one side channel of a certain id during communication.
19+
- `OnMessageReceived(IncomingMessage msg)` : You must implement this method and
20+
read the data from IncomingMessage. The data must be read in the order that it
21+
was written.
2222

23-
To send data from C# to Python, create an `OutgoingMessage` instance, add data to it, call the
24-
`base.QueueMessageToSend(msg)` method inside the side channel, and call the
25-
`OutgoingMessage.Dispose()` method.
23+
The side channel must also assign a `ChannelId` property in the constructor. The
24+
`ChannelId` is a Guid (or UUID in Python) used to uniquely identify a side
25+
channel. This Guid must be the same on C# and Python. There can only be one side
26+
channel of a certain id during communication.
2627

27-
To register a side channel on the Unity side, call `SideChannelManager.RegisterSideChannel` with the side channel
28-
as only argument.
28+
To send data from C# to Python, create an `OutgoingMessage` instance, add data
29+
to it, call the `base.QueueMessageToSend(msg)` method inside the side channel,
30+
and call the `OutgoingMessage.Dispose()` method.
31+
32+
To register a side channel on the Unity side, call
33+
`SideChannelManager.RegisterSideChannel` with the side channel as only argument.
2934

3035
### Python side
31-
The side channel will have to implement the `SideChannel` abstract class. You must implement :
3236

33-
* `on_message_received(self, msg: "IncomingMessage") -> None` : You must implement this method and read the data
34-
from IncomingMessage. The data must be read in the order that it was written.
37+
The side channel will have to implement the `SideChannel` abstract class. You
38+
must implement :
39+
40+
- `on_message_received(self, msg: "IncomingMessage") -> None` : You must
41+
implement this method and read the data from IncomingMessage. The data must be
42+
read in the order that it was written.
3543

36-
The side channel must also assign a `channel_id` property in the constructor. The `channel_id` is a UUID
37-
(referred in C# as Guid) used to uniquely identify a side channel. This number must be the same on C# and
38-
Python. There can only be one side channel of a certain id during communication.
44+
The side channel must also assign a `channel_id` property in the constructor.
45+
The `channel_id` is a UUID (referred in C# as Guid) used to uniquely identify a
46+
side channel. This number must be the same on C# and Python. There can only be
47+
one side channel of a certain id during communication.
3948

40-
To assign the `channel_id` call the abstract class constructor with the appropriate `channel_id` as follows:
49+
To assign the `channel_id` call the abstract class constructor with the
50+
appropriate `channel_id` as follows:
4151

4252
```python
4353
super().__init__(my_channel_id)
4454
```
4555

46-
To send a byte array from Python to C#, create an `OutgoingMessage` instance, add data to it, and call the
47-
`super().queue_message_to_send(msg)` method inside the side channel.
56+
To send a byte array from Python to C#, create an `OutgoingMessage` instance,
57+
add data to it, and call the `super().queue_message_to_send(msg)` method inside
58+
the side channel.
4859

49-
To register a side channel on the Python side, pass the side channel as argument when creating the
50-
`UnityEnvironment` object. One of the arguments of the constructor (`side_channels`) is a list of side channels.
60+
To register a side channel on the Python side, pass the side channel as argument
61+
when creating the `UnityEnvironment` object. One of the arguments of the
62+
constructor (`side_channels`) is a list of side channels.
5163

5264
## Example implementation
5365

54-
Below is a simple implementation of a side channel that will exchange ascii encoded
55-
strings between a Unity environment and Python.
66+
Below is a simple implementation of a side channel that will exchange ASCII
67+
encoded strings between a Unity environment and Python.
5668

5769
### Example Unity C# code
5870

59-
The first step is to create the `StringLogSideChannel` class within the Unity project.
60-
Here is an implementation of a `StringLogSideChannel` that will listen for messages
61-
from python and print them to the Unity debug log, as well as send error messages
62-
from Unity to python.
71+
The first step is to create the `StringLogSideChannel` class within the Unity
72+
project. Here is an implementation of a `StringLogSideChannel` that will listen
73+
for messages from python and print them to the Unity debug log, as well as send
74+
error messages from Unity to python.
6375

6476
```csharp
6577
using UnityEngine;
@@ -100,10 +112,10 @@ Once we have defined our custom side channel class, we need to ensure that it is
100112
instantiated and registered. This can typically be done wherever the logic of
101113
the side channel makes sense to be associated, for example on a MonoBehaviour
102114
object that might need to access data from the side channel. Here we show a
103-
simple MonoBehaviour object which instantiates and registeres the new side
104-
channel. If you have not done it already, make sure that the MonoBehaviour
105-
which registers the side channel is attached to a gameobject which will
106-
be live in your Unity scene.
115+
simple MonoBehaviour object which instantiates and registers the new side
116+
channel. If you have not done it already, make sure that the MonoBehaviour which
117+
registers the side channel is attached to a GameObject which will be live in
118+
your Unity scene.
107119

108120
```csharp
109121
using UnityEngine;
@@ -148,7 +160,8 @@ public class RegisterStringLogSideChannel : MonoBehaviour
148160

149161
### Example Python code
150162

151-
Now that we have created the necessary Unity C# classes, we can create their Python counterparts.
163+
Now that we have created the necessary Unity C# classes, we can create their
164+
Python counterparts.
152165

153166
```python
154167
from mlagents_envs.environment import UnityEnvironment
@@ -183,10 +196,9 @@ class StringLogChannel(SideChannel):
183196
super().queue_message_to_send(msg)
184197
```
185198

186-
187-
We can then instantiate the new side channel,
188-
launch a `UnityEnvironment` with that side channel active, and send a series of
189-
messages to the Unity environment from Python using it.
199+
We can then instantiate the new side channel, launch a `UnityEnvironment` with
200+
that side channel active, and send a series of messages to the Unity environment
201+
from Python using it.
190202

191203
```python
192204
# Create the channel
@@ -210,7 +222,7 @@ for i in range(1000):
210222
env.close()
211223
```
212224

213-
Now, if you run this script and press `Play` the Unity Editor when prompted,
214-
the console in the Unity Editor will display a message at every Python step.
225+
Now, if you run this script and press `Play` the Unity Editor when prompted, the
226+
console in the Unity Editor will display a message at every Python step.
215227
Additionally, if you press the Space Bar in the Unity Engine, a message will
216228
appear in the terminal.

0 commit comments

Comments
 (0)