AttributeError:“计时器"对象没有属性"_seed" [英] AttributeError: 'Timer' object has no attribute '_seed'

查看:117
本文介绍了AttributeError:“计时器"对象没有属性"_seed"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我使用的代码.我在 https://github.com/openai/universe#breaking找到此代码-down-the-example .由于我在远程管理器上遇到错误,因此我必须复制此代码以运行它.但这仍然给我以下错误

This is the code I used. I found this code on https://github.com/openai/universe#breaking-down-the-example . As I'm getting error on remote manager so I have to copy this code to run it. But it still giving me error as below

import gym
import universe  # register the universe environments

    env = gym.make('flashgames.DuskDrive-v0')
    env.configure(remotes=1)  # automatically creates a local docker container
    observation_n = env.reset()

    while True:
      action_n = [[('KeyEvent', 'ArrowUp', True)] for ob in observation_n]  # your agent here
      observation_n, reward_n, done_n, info = env.step(action_n)
      env.render()

尝试在上述脚本上运行时得到此提示.我尝试了所有可能的方法来解决它,但仍然会导致相同的错误.甚至没有一个线程.我现在不知道该怎么办,请告诉我你们中是否有人解决过这个问题.

I'm getting this when try to run above script. I tried every possible way to solve it, but it still causing the same error. There is not even one thread about this. I don't know what to do now please tell me if anyone of you solved it.

我在Windows 10上运行的虚拟机上使用Ubuntu 18.04 LTS

I'm using Ubuntu 18.04 LTS on virtual box which is running on Windows 10

    WARN: Environment '<class 'universe.wrappers.timer.Timer'>' has deprecated methods '_step' and '_reset' rather than 'step' and 'reset'. Compatibility code invoked. Set _gym_disable_underscore_compat = True to disable this behavior.
Traceback (most recent call last):
  File "gymtest1.py", line 4, in <module>
    env = gym.make("flashgames.CoasterRacer-v0")
  File "/home/mystery/.local/lib/python3.6/site-packages/gym/envs/registration.py", line 167, in make
    return registry.make(id)
  File "/home/mystery/.local/lib/python3.6/site-packages/gym/envs/registration.py", line 125, in make
    patch_deprecated_methods(env)
  File "/home/mystery/.local/lib/python3.6/site-packages/gym/envs/registration.py", line 185, in patch_deprecated_methods
    env.seed  = env._seed
AttributeError: 'Timer' object has no attribute '_seed'

推荐答案

所以我认为您需要在

So I think what you need to do add a few lines in the Timer module because the code checks whether the code implements certain functions (_step, _reset, _seed, etc...)

因此,您需要做的(我认为)是在Timer类的末尾添加:

So all you need to do (I think) is add at the end of the Timer class:

def _seed(self, seed_num=0): # this is so that you can get consistent results
    pass                     # optionally, you could add: random.seed(random_num)
    return

这篇关于AttributeError:“计时器"对象没有属性"_seed"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆