遇到的问题
执行keras的预测程序时,在载入网络权重数据时出现
AttributeError: 'str' object has no attribute 'decode'
参考:
keras与h5py版本不兼容
pip install h5py==2.10
将h5py降级
出现新问题:
AttributeError: 'bytes' object has no attribute 'encode'
原因
python3中,编码的时候区分了字符串和二进制
python3在bytes和str两种类型转换,所需要的函数依次是encode(),decode()
详细:
浅析Python3中的bytes和str类型
解决方案
找到报错的文件,将bytes类型数据n
后的.encode(‘utf-8’)删除即可。