openai 健身房 env.P,AttributeError 'TimeLimit' 对象没有属性 'P'

问题描述 投票:0回答:4

我目前正在阅读 Sudharsan Ravichandiran 的《Python 强化学习实践》,在我遇到这个 AttributeError 的第一个示例中:

AttributeError 'TimeLimit' object has no attribute 'P'


由以下行提出:

for next_sr in env.P[state][action]:

我找不到任何有关 
env.P

的文档,但我在这里找到了用 python2 编写的类似示例:https://gym.openai.com/evaluations/eval_48sirBRSRAapMjotYzjb6w/ 我想

env.P

是过时库的一部分(即使这本书是在 2018 年 6 月出版的,并且有罪的代码是 python3 中的),那么我该如何替换它呢?

python python-3.x reinforcement-learning openai-gym
4个回答
12
投票

env = env.unwrapped

    


0
投票

for next_sr in env.env.P[state][action]:

注意开始时额外的“env”

对于一般用途,请尝试

>>> dir(class_name)

这将给出成员函数列表。


0
投票
此 github 问题链接

中提出的解决方案对我有用。 正如github问题中所解释的,最新版本的gym中的监控已被包装器取代,因此监控不适用于最新的gym。要在最新版本的 Gym 中重新实现监控,请更改类似于以下内容的代码:

env.monitor.start('cartpole-hill/', force=True)

env = gym.wrappers.Monitor(env,directory='cartpole-hill/',force=True,write_upon_reset=True)



0
投票

max_steps = args.max_timesteps or env.spec.max_episode_steps

© www.soinside.com 2019 - 2024. All rights reserved.