简体   繁体   English

在 rllib 中注册健身房环境时传递可选的 arguments

[英]Passing optional arguments when registering gym environment in rllib

I've been following the helpful example here to create a custom environment in gym, which I then want to train in rllib.我一直在按照这里有用的示例在健身房中创建一个自定义环境,然后我想在 rllib 中进行训练。

My environment has some optional parameters which I would like to select when training.我的环境有一些可选参数,我想在训练时使用 select。 I think the relevant part of code is in train.py here:我认为代码的相关部分在train.py中:

    # start Ray -- add `local_mode=True` here for debugging
    ray.init(ignore_reinit_error=True)

    # register the custom environment
    select_env = "example-v0"
    register_env(select_env, lambda config: Example_v0())

I've tried some obvious things, like我尝试了一些明显的东西,比如

    register_env(select_env, lambda config: Example_v0(optional_arg=n))

but nothing has seemed to work.但似乎没有任何效果。 Is there a way to pass different arguments before training?有没有办法在训练前通过不同的arguments?

I think you should use env_config in the constructor and then pass the dictionary env_config = {'optional_arg': n}我认为你应该在构造函数中使用 env_config 然后传递字典 env_config = {'optional_arg': n}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM