当前位置:网站首页>解决: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版本
最终完成安装
打开设置看一下
安装成功!
希望对看到的同学有用~
这里安装过程报了另外一个错误,如有解决办法,欢迎留言交流~
边栏推荐
- Patch NTP server at the beginning of DDoS counterattack
- Black high-end responsive website dream weaving template (adaptive mobile terminal)
- PAT甲级 1033 To Fill or Not to Fill
- Redis installation
- A copy can also produce flowers
- 【社区人物志】专访马龙伟:轮子不好用,那就自己造!
- Crawler (9) - scrape framework (1) | scrape asynchronous web crawler framework
- sql表名作为参数传递
- HttpRunnerManager安装(三)-Linux下配置myql数据库&初始化数据
- Ue4- how to make a simple TPS role (II) - realize the basic movement of the role
猜你喜欢
【社区人物志】专访马龙伟:轮子不好用,那就自己造!
A doctor's 22 years in Huawei
Minecraft 1.18.1, 1.18.2 module development 22 Sniper rifle
纯Qt版中国象棋:实现双人对战、人机对战及网络对战
2345 file shredding, powerful file deletion tool, unbound pure extract version
How to generate rich text online
Pure QT version of Chinese chess: realize two-man, man-machine and network games
Building the prototype of library functions -- refer to the manual of wildfire
[Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 8
一个复制也能玩出花来
随机推荐
DDoS "fire drill" service urges companies to be prepared
Dachang image library
Minecraft 1.16.5 biochemical 8 module version 2.0 storybook + more guns
零基础自学STM32-复习篇2——使用结构体封装GPIO寄存器
微软语音合成助手 v1.3 文本转语音工具,真实语音AI生成器
有沒有sqlcdc監控多張錶 再關聯後 sink到另外一張錶的案例啊?全部在 mysql中操作
2020.02.11
Easy to use js script
Pat grade a 1033 to fill or not to fill
零基础自学STM32-野火——GPIO复习篇——使用绝对地址操作GPIO
数据准备工作
Spherical lens and cylindrical lens
米家、涂鸦、Hilink、智汀等生态哪家强?5大主流智能品牌分析
High number_ Vector algebra_ Unit vector_ Angle between vector and coordinate axis
Minecraft 1.18.1, 1.18.2 module development 22 Sniper rifle
Zero foundation self-study STM32 - Review 2 - encapsulating GPIO registers with structures
HDU_p1237_简单计算器_stack
Large scale DDoS attacks take Myanmar offline
Template_ Find the reverse pair of permutations_ Sort based on merge
继承的构造函数