浏览代码

Fix Baselines gym_unity example to work with the latest Baselines (#2489)

* This addresses #1835. Baselines expects single environments used with their ppo2 algorithm to be wrapped in a DummyVecEnv. The old readme did not instruct the reader to do so and the code failed to run with the latest version of baselines. This imports the correct function from baselines and fixes the make_unity_env function described in the readme.

* added line to gym-unity/README.md to note the version of baselines the examples were tested with
/develop-gpu-test
Ervin T 5 年前
当前提交
6fb5b63c
共有 1 个文件被更改,包括 4 次插入1 次删除
  1. 5
      gym-unity/README.md

5
gym-unity/README.md


launch each algorithm. In most cases these scripts can be created by making
slight modifications to the ones provided for Atari and Mujoco environments.
These examples were tested with baselines version 0.1.6.
### Example - DQN Baseline
In order to train an agent to play the `GridWorld` environment using the

```python
from gym_unity.envs import UnityEnv
from baselines.common.vec_env.subproc_vec_env import SubprocVecEnv
from baselines.common.vec_env.dummy_vec_env import DummyVecEnv
from baselines.bench import Monitor
from baselines import logger
import baselines.ppo2.ppo2 as ppo2

return SubprocVecEnv([make_env(i + start_index) for i in range(num_env)])
else:
rank = MPI.COMM_WORLD.Get_rank() if MPI else 0
return make_env(rank, use_visual=False)
return DummyVecEnv([make_env(rank, use_visual=False)])
def main():
env = make_unity_env('./envs/GridWorld', 4, True)

正在加载...
取消
保存