Skip to content

Commit 91af77a

Browse files
Merge pull request #4707 from Unity-Technologies/develop-rm-tf
Removing TensorFlow Trainers
2 parents 1f48c23 + e31d90f commit 91af77a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

74 files changed

+113
-9200
lines changed

.github/workflows/pytest.yml

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,8 @@ jobs:
2020
python-version: [3.6.x, 3.7.x, 3.8.x]
2121
include:
2222
- python-version: 3.6.x
23-
pip_constraints: test_constraints_min_version.txt
2423
- python-version: 3.7.x
25-
pip_constraints: test_constraints_max_tf1_version.txt
2624
- python-version: 3.8.x
27-
pip_constraints: test_constraints_max_tf2_version.txt
2825
steps:
2926
- uses: actions/checkout@v2
3027
- name: Set up Python
@@ -37,7 +34,7 @@ jobs:
3734
# This path is specific to Ubuntu
3835
path: ~/.cache/pip
3936
# Look to see if there is a cache hit for the corresponding requirements file
40-
key: ${{ runner.os }}-pip-${{ hashFiles('ml-agents/setup.py', 'ml-agents-envs/setup.py', 'gym-unity/setup.py', 'test_requirements.txt', matrix.pip_constraints) }}
37+
key: ${{ runner.os }}-pip-${{ hashFiles('ml-agents/setup.py', 'ml-agents-envs/setup.py', 'gym-unity/setup.py', 'test_requirements.txt') }}
4138
restore-keys: |
4239
${{ runner.os }}-pip-
4340
${{ runner.os }}-
@@ -48,10 +45,10 @@ jobs:
4845
# pin pip to workaround https://github.com/pypa/pip/issues/9180
4946
python -m pip install pip==20.2
5047
python -m pip install --upgrade setuptools
51-
python -m pip install --progress-bar=off -e ./ml-agents-envs -c ${{ matrix.pip_constraints }}
52-
python -m pip install --progress-bar=off -e ./ml-agents -c ${{ matrix.pip_constraints }}
53-
python -m pip install --progress-bar=off -r test_requirements.txt -c ${{ matrix.pip_constraints }}
54-
python -m pip install --progress-bar=off -e ./gym-unity -c ${{ matrix.pip_constraints }}
48+
python -m pip install --progress-bar=off -e ./ml-agents-envs
49+
python -m pip install --progress-bar=off -e ./ml-agents
50+
python -m pip install --progress-bar=off -r test_requirements.txt
51+
python -m pip install --progress-bar=off -e ./gym-unity
5552
- name: Save python dependencies
5653
run: |
5754
pip freeze > pip_versions-${{ matrix.python-version }}.txt

com.unity.ml-agents/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ and this project adheres to
1111
### Major Changes
1212
#### com.unity.ml-agents (C#)
1313
#### ml-agents / ml-agents-envs / gym-unity (Python)
14+
- TensorFlow trainers have been removed, please use the Torch trainers instead. (#4707)
1415
- PyTorch trainers now support training agents with both continuous and discrete action spaces. (#4702)
1516
### Minor Changes
1617
#### com.unity.ml-agents / com.unity.ml-agents.extensions (C#)

docs/ML-Agents-Overview.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@ your agent's behavior:
372372
below).
373373
- `rnd`: represents an intrinsic reward signal that encourages exploration
374374
in sparse-reward environments that is defined by the Curiosity module (see
375-
below). (Not available for TensorFlow trainers)
375+
below).
376376

377377
### Deep Reinforcement Learning
378378

@@ -437,8 +437,6 @@ of the trained model is used as intrinsic reward. The more an Agent visits a sta
437437
more accurate the predictions and the lower the rewards which encourages the Agent to
438438
explore new states with higher prediction errors.
439439

440-
__Note:__ RND is not available for TensorFlow trainers (only PyTorch trainers)
441-
442440
### Imitation Learning
443441

444442
It is often more intuitive to simply demonstrate the behavior we want an agent

docs/Training-Configuration-File.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ choice of the trainer (which we review on subsequent sections).
3232
| `time_horizon` | (default = `64`) How many steps of experience to collect per-agent before adding it to the experience buffer. When this limit is reached before the end of an episode, a value estimate is used to predict the overall expected reward from the agent's current state. As such, this parameter trades off between a less biased, but higher variance estimate (long time horizon) and more biased, but less varied estimate (short time horizon). In cases where there are frequent rewards within an episode, or episodes are prohibitively large, a smaller number can be more ideal. This number should be large enough to capture all the important behavior within a sequence of an agent's actions. <br><br> Typical range: `32` - `2048` |
3333
| `max_steps` | (default = `500000`) Total number of steps (i.e., observation collected and action taken) that must be taken in the environment (or across all environments if using multiple in parallel) before ending the training process. If you have multiple agents with the same behavior name within your environment, all steps taken by those agents will contribute to the same `max_steps` count. <br><br>Typical range: `5e5` - `1e7` |
3434
| `keep_checkpoints` | (default = `5`) The maximum number of model checkpoints to keep. Checkpoints are saved after the number of steps specified by the checkpoint_interval option. Once the maximum number of checkpoints has been reached, the oldest checkpoint is deleted when saving a new checkpoint. |
35-
| `checkpoint_interval` | (default = `500000`) The number of experiences collected between each checkpoint by the trainer. A maximum of `keep_checkpoints` checkpoints are saved before old ones are deleted. Each checkpoint saves the `.onnx` (and `.nn` if using TensorFlow) files in `results/` folder.|
35+
| `checkpoint_interval` | (default = `500000`) The number of experiences collected between each checkpoint by the trainer. A maximum of `keep_checkpoints` checkpoints are saved before old ones are deleted. Each checkpoint saves the `.onnx` files in `results/` folder.|
3636
| `init_path` | (default = None) Initialize trainer from a previously saved model. Note that the prior run should have used the same trainer configurations as the current run, and have been saved with the same version of ML-Agents. <br><br>You should provide the full path to the folder where the checkpoints were saved, e.g. `./models/{run-id}/{behavior_name}`. This option is provided in case you want to initialize different behaviors from different runs; in most cases, it is sufficient to use the `--initialize-from` CLI parameter to initialize all models from the same run. |
3737
| `threaded` | (default = `true`) By default, model updates can happen while the environment is being stepped. This violates the [on-policy](https://spinningup.openai.com/en/latest/user/algorithms.html#the-on-policy-algorithms) assumption of PPO slightly in exchange for a training speedup. To maintain the strict on-policyness of PPO, you can disable parallel updates by setting `threaded` to `false`. There is usually no reason to turn `threaded` off for SAC. |
3838
| `hyperparameters -> learning_rate` | (default = `3e-4`) Initial learning rate for gradient descent. Corresponds to the strength of each gradient descent update step. This should typically be decreased if training is unstable, and the reward does not consistently increase. <br><br>Typical range: `1e-5` - `1e-3` |

docs/Training-ML-Agents.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -317,9 +317,6 @@ behaviors:
317317
save_steps: 50000
318318
swap_steps: 2000
319319
team_change: 100000
320-
321-
# use TensorFlow backend
322-
framework: tensorflow
323320
```
324321

325322
Here is an equivalent file if we use an SAC trainer instead. Notice that the

docs/Unity-Inference-Engine.md

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,6 @@ Graphics Emulation is set to **OpenGL(ES) 3.0 or 2.0 emulation**. Also there
1919
might be non-fatal build time errors when target platform includes Graphics API
2020
that does not support **Unity Compute Shaders**.
2121

22-
## Supported formats
23-
24-
There are currently two supported model formats:
25-
26-
- Barracuda (`.nn`) files use a proprietary format produced by the
27-
[`tensorflow_to_barracuda.py`]() script.
28-
- ONNX (`.onnx`) files use an
29-
[industry-standard open format](https://onnx.ai/about.html) produced by the
30-
[tf2onnx package](https://github.com/onnx/tensorflow-onnx).
31-
32-
Export to ONNX is used if using PyTorch (the default). To enable it
33-
while using TensorFlow, make sure `tf2onnx>=1.6.1` is installed in pip.
34-
3522
## Using the Unity Inference Engine
3623

3724
When using a model, drag the model file into the **Model** field in the
@@ -56,7 +43,5 @@ If you wish to run inference on an externally trained model, you should use
5643
Barracuda directly, instead of trying to run it through ML-Agents.
5744

5845
## Model inference outside of Unity
59-
We do not provide support for inference anywhere outside of Unity. The
60-
`frozen_graph_def.pb` and `.onnx` files produced by training are open formats
61-
for TensorFlow and ONNX respectively; if you wish to convert these to another
46+
We do not provide support for inference anywhere outside of Unity. The `.onnx` files produced by training use the open format ONNX; if you wish to convert a `.onnx` file to another
6247
format or run inference with them, refer to their documentation.

ml-agents-envs/setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ def run(self):
4848
install_requires=[
4949
"cloudpickle",
5050
"grpcio>=1.11.0",
51-
"numpy>=1.14.1,<1.19.0",
51+
"numpy>=1.14.1",
5252
"Pillow>=4.2.1",
5353
"protobuf>=3.6",
5454
"pyyaml>=3.1.0",

ml-agents/mlagents/tf_utils/__init__.py

Lines changed: 0 additions & 4 deletions
This file was deleted.

ml-agents/mlagents/tf_utils/tf.py

Lines changed: 0 additions & 60 deletions
This file was deleted.
File renamed without changes.

0 commit comments

Comments
 (0)