解决:AttributeError: ‘str‘ object has no attribute ‘decode‘
目录
1环境介绍
2报错信息:
3问题分析
4问题查找
5最终解决
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版本
最终完成安装
打开设置看一下
安装成功!
希望对看到的同学有用~
这里安装过程报了另外一个错误,如有解决办法,欢迎留言交流~
解决:AttributeError: ‘str‘ object has no attribute ‘decode‘相关推荐
- 成功解决AttributeError: ‘str‘ object has no attribute ‘decode‘
成功解决AttributeError: 'str' object has no attribute 'decode' 目录 解决问题 解决思路 解决方法 T1.直接去掉 T2.众多网友好评的建议 解决 ...
- 解决AttributeError: 'str' object has no attribute 'decode'报错问题
顺着报错文件点进去,找到query = query.decode(errors='replace') 将decode修改为encode即可
- 成功解决keras库中出现AttributeError: ‘str‘ object has no attribute ‘decode‘
成功解决keras库中出现AttributeError: 'str' object has no attribute 'decode' 目录 解决问题 解决思路 解决方法 解决问题 Attribute ...
- 成功解决tensorflow.keras: AttributeError: ‘str‘ object has no attribute ‘decode‘
tensorflow.keras: AttributeError: 'str' object has no attribute 'decode' 出现该问题,解决分两步首先检测自身的版本是否对应, 然 ...
- AttributeError: 'str' object has no attribute 'decode' django问题
AttributeError: 'str' object has no attribute 'decode' 错误代码:query = query.encode(errors='replace') 解 ...
- 已解决AttributeError: ‘str‘ object has no attribute ‘apply‘
已解决(pandas apply函数使用报错)AttributeError: 'str' object has no attribute 'apply' 文章目录 报错代码 报错翻译 报错原因 解决方 ...
- python编程 报错解决:“AttributeError: ‘str‘ object has no attribute ‘decode‘”
简介 在做django项目遇到了如题的报错,通过搜索分析是encode/decode的问题,我的decode/encode并没有出现在我编写的代码中,而是在D:\python\Lib\site-pac ...
- AttributeError: 'str' object has no attribute 'decode'
错误代码: name = student['name'].decode("gbk") 解决办法:把后面的 .decode("gbk") 删除即可 转载 ...
- 解决AttributeError: ‘str‘ object has no attribute ‘append‘
很明显这是字符串不能完成append的函数 这里举一个我遇到的例子, 在这里.你需要改正一下方法. 将32行改成 imagese.append(str(count)), 需要注意的是字符串的方法有很多 ...
- “AttributeError: ‘str‘ object has no attribute ‘decode‘ “
pip install h5py==2.10 -i https://pypi.doubanio.com/simple link
最新文章
- 浮点类型和布尔类型(Java)
- 清华 NLP 团队推荐:必读的77篇机器阅读理解论文
- git clone的时候报error: RPC failed; result=18错误
- OpenCV中矩阵的归一化*(Normalize函数)
- 使用线程池有以下几个目的
- Concurrent——Atomic原子操作类
- 【并查集】团伙(luogu 1892)
- 多线程的线程通信(生产消费)
- 谷歌浏览器如何将繁体字设置成中文?
- Atitit 流水线子线程异常处理 1.1. 大概原理是 FutureTask排除异常 FutureTask.get can throw ExecutionException,can catc
- 【PDN仿真笔记4-电容布局仿真及结果分析】
- FACEBOOK改名META,元宇宙救不了FACEBOOK
- XP突然弹出“automation 服务器不能创建对象”的有效解决方法--win10专业版
- java.lang.exceptionininitializererror_解决出现 java.lang.ExceptionInInitializerError错误问题
- 织梦cms里面文章里面的HTML,dede源码在其它页面调用单页文章内容并过滤HTML代码的方法...
- stm32使用XR20M1172详细攻略·SPI转UART串口
- 携程平台增长部总经理王绩强:原生互联网企业正在经历一场数字升级丨数据猿专访...
- 代理模式相关简单论述
- 打包chromium浏览器
- Java核心技术卷一(百度云资源)