use*_*113 7 reinforcement-learning openai-gym
使用OpenAIgym时,使用 导入库后import gym
,可以使用 来查看动作空间env.action_space
。但这仅给出了动作空间的大小。我想知道动作空间的每个元素对应什么样的动作。有简单的方法吗?
如果你的动作空间是离散的和一维的,env.action_space
会给你一个Discrete
对象。您可以像这样访问可用操作的数量(只是一个整数):
env = gym.make("Acrobot-v1")
a = env.action_space
print(a) #prints Discrete(3)
print(a.n) #prints 3
Run Code Online (Sandbox Code Playgroud)
如果您的操作空间是离散且多维的,您将获得一个MultiDiscrete
(而不是Discrete
)对象,您可以在该对象上调用nvec
(而不是n
)来获取描述每个维度的可用操作数量的数组。但请注意,这并不是一个很常见的情况。
如果你有一个连续的动作空间,env.action_space
就会给你一个Box
物体。以下是访问其属性的方法:
env = gym.make("MountainCarContinuous-v0")
a = env.action_space
print(a) #prints Box(1,)
print(a.shape) #prints (1,), note that you can do a.shape[0] which is 1 here
print(a.is_bounded()) #prints True if your action space is bounded
print(a.high) #prints [1.] an array with the maximum value for each dim
print(a.low) #prints [-1.] same for minimum value
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
10368 次 |
最近记录: |