神奇的h5py包:保存h5模型,却只有0KB 2.Process finished with exit code -1073741819 (0xC0000005)

1.h5py相关的问题遇到过好几次了,保存模型或者加载模型的时候,出现问题,有50%的概率是h5py版本问题。

原本运行顺利,成功收敛的代码,到了保存模型时只有一个文件命名,没有内容。

同时运行结束后无红色错误提示,只有

Process finished with exit code -1073741819 (0xC0000005)

解决办法:重装tensorflow,keras,以及h5py

选择合适且对应的版本,如下图

在安装过程中还遇到了RuntimeError: module compiled against API version 0xc but this version of numpy is 0xb这个问题,遇到该问题时nump版本为1.19.5,查了别人的解答是卸掉重装。

命令行运行pip uninstall numpy

然后pip install numpy

报错:numpy已存在

这时pip list发现电脑还存在numpy.1.13.3的版本,所以还需卸载一次,再重新下载。查了网上的解答,也存在这种情况。一翻折腾之后,h5模型能正确保存下来不是空壳了。

2.AttributeError: ‘str‘ object has no attribute ‘decode‘

加载模型时报错:属性错误:“str”对象没有属性“decode”
python3.5和Python2.7在套接字返回值解码上的区别 
python在bytes和str两种类型转换,所需要的函数依次是encode(),decode()

解决办法:安装h5py<3.0.0版本

成功解决AttributeError: ‘str‘ object has no attribute ‘decode‘

猜你喜欢

转载自blog.csdn.net/sky_ying/article/details/125086856