解决:强化学习FrozenLake代码出现KeyError: ‘FrozenLake-v0‘错误、 Consider using IPython.display.IFrame instead错误

问题:

在学习强化学习时,出现**KeyError: ‘FrozenLake-v0’**错误

具体信息如下:
Traceback (most recent call last):
File “D:\InstallPosition\python3.7.3\lib\site-packages\gym\envs\registration.py”, line 158, in spec
return self.env_specs[id]
KeyError: ‘FrozenLake-v0’

Traceback (most recent call last):
  File "D:\registration.py", line 158, in spec
    return self.env_specs[id]
KeyError: 'FrozenLake-v0'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:/test.py", line 7, in <module>
    env = gym.make("FrozenLake-v0")
  File "D:\registration.py", line 235, in make
    return registry.make(id, **kwargs)
  File "D:\registration.py", line 128, in make
    spec = self.spec(path)
  File "D:\registration.py", line 187, in spec
    id, matching_envs
gym.error.DeprecatedEnv: Env FrozenLake-v0 not found (valid versions include ['FrozenLake-v1'])

进程已结束,退出代码 1

原因及解决措施:

后来查了查,原因很简单,只是FrozenLake-v0的版本问题,原来的v0版本没有了,现在改为-v1即可,即:FrozenLake-v1。在源代码处改完了,代码立即没有问题了~~开森森(o゚▽゚)o ヾ(✿゚▽゚)ノ

附部分正确代码如下:

import gym
import random

env = gym.make("FrozenLake-v1")
env.reset()
env.render()

action_size = env.action_space.n
state_size = env.observation_space.n

有兴趣的童鞋们赶紧试一试吧!(๑>ڡ<)☆

NOTE:

部分FrozenLake代码中还导入了依赖:

from IPython.display import HTML
HTML('<iframe width="50" height="35" src="**********" frameborder="0" allow="autoplay; encrypted-media" allowfullscreen></iframe>')

出现错误如下:

UserWarning: Consider using IPython.display.IFrame instead
  warnings.warn("Consider using IPython.display.IFrame instead")

这个报错不要紧,很有可能就是开源代码做广告的,注释掉就好咯~~有兴趣的童鞋可以告诉我如果想要保留,报错应该如何解决呢?欢迎大家交流!

  • 3
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值