好的,OpenAI健身房必须有一些选项可以让它尽快运行吗?我有一个linux环境可以做到这一点(尽可能快地运行),但是当我在Windows上运行确切的设置时,它只是实时运行它。
我正在处理的具体环境是在Montezuma的Revenge Atari游戏中。我运行完全相同的代码,但在我的Linux设置,它能够更快地运行游戏。只是因为你知道我的linux计算机的规格比我的windows更差。
这里有一些代码可供那些想要它的人使用:
for i in range(episode_count):
ob = env.reset()
ob = np.expand_dims(ob, axis=0)
time = 0
while True:
time += 1
action = agent.act(ob, reward, done)
new_ob, reward, done, _ = env.step(action)
new_ob = np.expand_dims(new_ob, axis=0)
agent.remember(ob, action, reward, new_ob, done)
ob = new_ob
env.render()
if done or time >= 1000:
print("episode: {}/{}, time: {}, e: {:.3}"
.format(i, episode_count, time, agent.epsilon))
if len(agent.memory) > batch_size:
agent.replay(batch_size)
# agent.save("./save/montazuma-dqn.h5")
break
同样的事情在两个设置上运行,在运行速度上得到不同的结果。
答案 0 :(得分:1)
对于将来关注此问题的任何人,都是因为 self.env.render()
。我花了一些时间来弄清楚是什么让我的代码变慢了。最终呈现每个动作都需要时间,这会降低您的代码速度