首页 > 其他分享 >tf-agent 报错 ValueError 解决记录

tf-agent 报错 ValueError 解决记录

时间:2023-10-24 22:11:43浏览次数:31  
标签:reset gym py agent agents tf 报错

摘要:

最近强化学习需要用到 tf-agents ,记录一下使用过程遇到的问题。

版本说明:

tensorflow                    2.14.0
gym                           0.23.0
tf-agents                     0.17.0
numpy                         1.24.0
ale-py                        0.8.1

 

报错命令:

from tf_agents.environments import suite_gym
env = suite_gym.load("Breakout-v4")
env.reset() # 报错 ValueError: setting an array element with a sequence

报错信息:

2023-10-24 21:53:43.710604: I tensorflow/core/platform/cpu_feature_guard.cc:182] This TensorFlow binary is optimized to use available CPU instructions in performance-critical operations.
To enable the following instructions: AVX2 AVX512F FMA, in other operations, rebuild TensorFlow with the appropriate compiler flags.
2023-10-24 21:53:44.618709: W tensorflow/compiler/tf2tensorrt/utils/py_utils.cc:38] TF-TRT Warning: Could not find TensorRT
A.L.E: Arcade Learning Environment (version 0.7.5+db37282)
[Powered by Stella]

Traceback (most recent call last):
  File "/home/ys/215/gaoshd/test.py", line 3, in <module>
    env.reset()
  File "/home/ys/.conda/envs/gaoshd_tf/lib/python3.9/site-packages/tf_agents/environments/py_environment.py", line 195, in reset
    self._current_time_step = self._reset()
  File "/home/ys/.conda/envs/gaoshd_tf/lib/python3.9/site-packages/tf_agents/environments/gym_wrapper.py", line 199, in _reset
    observation = self._to_obs_space_dtype(observation)
  File "/home/ys/.conda/envs/gaoshd_tf/lib/python3.9/site-packages/tf_agents/environments/gym_wrapper.py", line 246, in _to_obs_space_dtype
    matched_observations.append(np.asarray(obs, dtype=spec.dtype))
ValueError: setting an array element with a sequence. The requested array has an inhomogeneous shape after 1 dimensions. The detected shape was (2,) + inhomogeneous part.

解决方案:

该报错原因一直纠结于是 numpy 版本的问题,其实不然,原因是 ale-py 的版本问题,0.8.1 版本会引起  ValueError 问题,降低一个版本即可。

pip install ale-py==0.7.5

 

标签:reset,gym,py,agent,agents,tf,报错
From: https://www.cnblogs.com/yueshang/p/17785849.html

相关文章

  • CTFshow逆向题目wp(1):基础篇
    re11.查看文件信息,64位elf文件2.使用64位ida打开,发现flag......
  • 【Azure App Service】App Service设置访问限制后,使用git clone代码库出现403报错
    问题描述在AppService中,为AppService配置了访问限制,结果导致在克隆AppService的代码时候,遇见403错误。  问题解答因为在使用gitcloneAppService的应用代码时,使用的URL地址为https://***.scm.chinacloudsites.cn/***.git,它是通过公网访问,并且会根据设定的访问限制......
  • pip 升级总是报错,显示什么utf-8之类的,一招解决
    想升级pip或者安装其它一些安装包的时候,pip总是报错,但是显示安装包其实已经下载完成了,就是安装的过程报错了,怎么也不行,删了pip再装还是一样,报错的界面大致如下: 不知道怎么解决,我还专门找到相应的文件,对编码方式进行修改,也不行,最后发现其实把Lib\site-packages\路径下的pip-xx.x......
  • FSCTF 2023(公开赛道)WP
    FSCTF2023ID:Mar10Rank:6总结:下次看到不正常报错一定重新安装一遍工具~~web源码!启动!就在源码注释里<!--师傅们,欢迎来到CTF的世界~NSSCTF{59a1d387-6eb8-40d0-828d-99ce32b3feb8}--->webshell是啥捏哭脸是passthru,那直接命令执行Hello,you源码有注释......
  • python 解析User-Agent
    需求:从User-Agent中获取浏览器信息和操作系统信息使用第三方库ua-parser安装pipinstallua-parser使用fromua_parser.user_agent_parserimportParse#解析user_agentparsed_user_agent=Parse(user_agent)print(parsed_user_agent)返回数据{"string":"Mozill......
  • Maven打包报错问题的解决-- No goals have been specified for this build. You must
    问题描述在使用maven执行打包操作时,出现了这样的错误:上面的图片是网上的图,我的图片忘记截图了;问题解决在我们创建的项目里面的pom.xml文件里面的dependencies标签后面,新建一个build标签,并在build标签里面放上这句代码:<defaultGoal>compile</defaultGoal>保存退出,然后重新......
  • npm 安装依赖报错整理
    1. [email protected]:`nodeinstall.js`npmERR!codeELIFECYCLEnpmERR!errno1npmERR!chromedriver@2.27.2install:`nodeinstall.js`npmERR!Exitstatus1npmERR!npmERR!Failedatthechromedriver@2.27.2installscript.npmER......
  • 8、SpringMVC之RESTful案例
    阅读本文前,需要先阅读SpringMVC之RESTful概述8.1、前期工作8.1.1、创建实体类Employeepackageorg.rain.pojo;importjava.io.Serializable;/***@authorliaojy*@date2023/10/19-21:31*/publicclassEmployeeimplementsSerializable{privateInte......
  • 为什么一些前端不喜欢 Restful Api?
    做过不少系统架构,全栈、前后端一起设计,我认为至少在部分领域restful可以扔了。第一个被淘汰的是URI风格,主要是现在都是纯JSON请求和返回,例如post一般情况下id都和JSON放一起提交了,就没URI的必要。然后既然post都润了,那get、put、delete也一样了。且在js代码里面单独为URI设置......
  • 宝塔:续签SSL证书报错string indices must be integers
    网站SSL证书过期,续签的时候,报错stringindicesmustbeintegers。  处理方法:1.点击左侧首页,选择“修复”; 2.修复之后,重新点击网站,设置>>>SSL>>>续签证书,等待流程通过,点击保存即可。 ......