Is it possible to modify OpenAI environments?

题意:“是否可以修改 OpenAI 环境?”

问题背景:

There are some things that I would like to modify in the OpenAI environments. If we use the Cartpole example then we can edit things that are in the class init function but with environments that use Box2D it doesn't seem to be as straightforward.

“我有一些想要修改的 OpenAI 环境。如果我们使用 Cartpole 示例,我们可以编辑类的初始化函数中的内容,但对于使用 Box2D 的环境,这似乎就不那么简单了。”

For example, consider the BipedalWalker environment.

“例如,考虑一下 BipedalWalker 环境。”

In this case, how would I edit things like the SPEED_HIP or SPEED_KNEE variables?

“在这种情况下,我该如何编辑像 SPEED_HIP 或 SPEED_KNEE 这样的变量?”

问题解决:

Yes, you can modify or create new environments in gym. The simplest (but not recommended) way is to modify the constants in your local gym installation directly, but of course that's not really nice.

“是的,你可以修改或创建新的 Gym 环境。最简单(但不推荐)的方法是直接修改你本地 Gym 安装中的常量,但这种做法并不优雅。”

A nicer way is to download the bipedal walker environment file (from here) and save it to a file (say, my_bipedal_walker.py)

“更好的方法是下载 Bipedal Walker 环境文件(从这里),并将其保存到一个文件中(比如,`my_bipedal_walker.py`)。”

Then you modify the constants in the my_bipedal_walker.py file, and then just import it in your code (assuming you put the file in a path that is importable, or the same folder as your other code files):

“然后你可以修改 `my_bipedal_walker.py` 文件中的常量,然后在你的代码中导入它(假设你将文件放在一个可以导入的路径中,或与其他代码文件在同一文件夹下)。”

import gym
from my_bipedal_walker import BipedalWalker
env = BipedalWalker()

Then you have the env variable being an instance of the environment, with your defined constants for the physics computation, which you can use with any RL algorithm.

“这样,`env` 变量就会成为环境的一个实例,使用你定义的物理计算常量,你可以将其用于任何强化学习算法。”

An even nicer way would be making your custom environment available in the OpenAI gym registry, which you can do by following the instructions here

“一个更好的方法是将你的自定义环境注册到 OpenAI Gym 注册表中,你可以按照 [这里](链接) 的说明进行操作。”

  • 20
    点赞
  • 21
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

营赢盈英

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值