[英]Tf Agents Parallel Py Environment With an Environment that has Input Parameters
Suppose you have an environment that has input parameters: for example, to create an instance you would use假设您有一个具有输入参数的环境:例如,要创建一个您将使用的实例
env_instance = MyEnv(var_1=3, var_2=5, ...)
Now suppose you want to create a parallel_py_environment using the environment "MyEnv"?现在假设您想使用环境“MyEnv”创建一个 parallel_py_environment ? Since you need input parameters, you cannot use
由于您需要输入参数,因此不能使用
tf_py_environment.TFPyEnvironment(parallel_py_environment.ParallelPyEnvironment([MyEnv]*int(n_envs)))
The solution is to create a super class:解决方法是创建一个超类:
class MyEnvPar(MyEnv):
def __init__(self):
super().__init__(var_1=3, var_2=5)
And then you can use然后你可以使用
tf_py_environment.TFPyEnvironment(parallel_py_environment.ParallelPyEnvironment([MyEnvPar]*int(n_envs)))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.