当前位置:网站首页>解决:AttributeError: ‘str‘ object has no attribute ‘decode‘
解决:AttributeError: ‘str‘ object has no attribute ‘decode‘
2022-07-06 02:35:00 【秉*】
目录
1环境介绍
深度学习框架版本及对应python环境版本如下:
TensorFlow2.1.0+keras2.3.1+python36
2报错信息:
File "D:\Python36\lib\site-packages\keras\engine\saving.py", line 492, in load_wrapper
return load_function(*args, **kwargs)
File "D:\Python36\lib\site-packages\keras\engine\saving.py", line 584, in load_model
model = _deserialize_model(h5dict, custom_objects, compile)
File "D:\Python36\lib\site-packages\keras\engine\saving.py", line 273, in _deserialize_model
model_config = json.loads(model_config.decode('utf-8'))
AttributeError: 'str' object has no attribute 'decode'
3问题分析
在上述的环境下,加载.h5深度学习模型,报字符无法解码的错误,大概率是某个包版本不兼容。具体是什么不兼容,从报错信息可以看到这一句:
model = _deserialize_model(h5dict, custom_objects, compile)
当前环境对h5文件处理的时候出现反序列化不可进行的问题,查找资料发现:
当我们安装tensorflow2.1.0的时候,附带会自动为我们安装后h5py的版本是3.1.0.然而tensorflow2.1.0支持h5py<3.0.0,这就是上述报错的根本原因。
4问题查找
网上搜索:
点进去第一个
发现很多支持python3.6的后h5py版本,到底用哪一个呢?
在进一步搜一下:
发现很多对应的,点进去查找自己对应的版本就可以了。上述只是展示一下找答案的方法,不涉任何其他目的。
5最终解决
首先卸载原来的h5py-3.1.0
接着安装匹配的h5py版本
最终完成安装
打开设置看一下
安装成功!
希望对看到的同学有用~
这里安装过程报了另外一个错误,如有解决办法,欢迎留言交流~
边栏推荐
- [Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 11
- How to check the lock information in gbase 8C database?
- 球面透镜与柱面透镜
- 【MySQL 15】Could not increase number of max_ open_ files to more than 10000 (request: 65535)
- vs code保存时 出现两次格式化
- 我把驱动换成了5.1.35,但是还是一样的错误,我现在是能连成功,但是我每做一次sql操作都会报这个
- Yyds dry inventory comparison of several database storage engines
- Pure QT version of Chinese chess: realize two-man, man-machine and network games
- Lecture 4 of Data Engineering Series: sample engineering of data centric AI
- [Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 21
猜你喜欢
Minecraft 1.16.5 生化8 模组 2.0版本 故事书+更多枪械
2022 edition illustrated network pdf
vs code保存时 出现两次格式化
Formatting occurs twice when vs code is saved
Minecraft 1.16.5 biochemical 8 module version 2.0 storybook + more guns
2022 China eye Expo, Shandong vision prevention and control exhibition, myopia, China myopia correction Exhibition
[Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 13
2022.02.13
[Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 24
Sword finger offer 29 Print matrix clockwise
随机推荐
更改对象属性的方法
General process of machine learning training and parameter optimization (discussion)
力扣今日題-729. 我的日程安排錶 I
[coppeliasim] 6-DOF path planning
【无标题】数据库中一条查询SQL执行的过程
inherited constructors
球面透镜与柱面透镜
SSM 程序集
零基础自学STM32-复习篇2——使用结构体封装GPIO寄存器
数据准备工作
[Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 18
[Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 12
剑指 Offer 29. 顺时针打印矩阵
[robot hand eye calibration] eye in hand
微软语音合成助手 v1.3 文本转语音工具,真实语音AI生成器
Global and Chinese market of commercial cheese crushers 2022-2028: Research Report on technology, participants, trends, market size and share
Shell脚本更新存储过程到数据库
729. My schedule I / offer II 106 Bipartite graph
Yyds dry inventory comparison of several database storage engines
[Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 22