使用 HDF5 库和 h5py 模块的交替错误
Alternating errors using HDF5 library and h5py module
我已经创建了一个 CNN 模型并尝试将其保存为 .h5 文件,然后加载该模型。我在 Anaconda 的虚拟环境中工作。有趣的是,我可以在虚拟环境中的 Jupyter Notebook 中毫无问题地做任何事情。但是,当我在终端中尝试 运行ning 时(加载模型,然后对其进行评估),它不起作用。我有一组交替错误,这些错误在网络上有解决方案,但这些解决方案要么导致死胡同,要么导致其他错误。
第一个错误:
Traceback (most recent call last):
File "MNIST.py", line 64, in <module>
main()
File "MNIST.py", line 62, in main
evaluate_model()
File "MNIST.py", line 54, in evaluate_model
model = models.load_model('final_model.h5')
File "C:\Users\Josh Cruz\Documents\.conda\envs\tensorflow\lib\site-packages\keras\engine\saving.py", line 492, in load_wrapper
return load_function(*args, **kwargs)
File "C:\Users\Josh Cruz\Documents\.conda\envs\tensorflow\lib\site-packages\keras\engine\saving.py", line 582, in load_model
if H5Dict.is_supported_type(filepath):
File "C:\Users\Josh Cruz\Documents\.conda\envs\tensorflow\lib\site-packages\keras\utils\io_utils.py", line 209, in is_supported_type
isinstance(path, h5py.Group) or
AttributeError: module 'h5py' has no attribute 'Group'
我还没有找到修复 Attribute Error: module 'h5py' has no attribute 'Group'
的特定修复程序,但我确实找到了 similar issues online,其解决方案建议我应该使用 conda install -c conda-forge h5py
将 h5py 更新到 2.10.0。这对我来说很有意义,因为组似乎是 2.10.0 h5py 文档的一部分。
安装后出现:
The following packages will be downloaded:
package | build
---------------------------|-----------------
h5py-2.9.0 |nompi_py36h9dfa0df_1103 909 KB conda-forge
------------------------------------------------------------
Total: 909 KB
The following NEW packages will be INSTALLED:
h5py conda-forge/win-64::h5py-2.9.0-nompi_py36h9dfa0df_1103
The following packages will be SUPERSEDED by a higher-priority channel:
certifi pkgs/main::certifi-2019.11.28-py36_1 --> conda-forge::certifi-2019.11.28-
py36h9f0ad1d_1
我很困惑,因为我以为我安装的是 2.10.0 版本。我还是安装了,尝试 re-run 我的程序并得到一个全新的错误:
Headers are 1.10.4, library is 1.10.5
SUMMARY OF THE HDF5 CONFIGURATION
=================================
General Information:
-------------------
HDF5 Version: 1.10.5
Configured on: 2019-03-04
Configured by: Visual Studio 14 2015 Win64
Host system: Windows-10.0.17763
Uname information: Windows
Byte sex: little-endian
Installation point: C:/Program Files/HDF5
为了space,我没有把整个错误都包括进去,但是整个错误可以在this question. The suggestion there is to do pip install h5py --upgrade --no-dependencies --force
, but doing that leads to the same error. Another source (which I can't find right now), says there might be issues juggling both installs of pip and conda, so I run pip uninstall h5py
, and the error persists. Then, using a suggestion here中找到,我运行conda install -c anaconda hdf5=1.10.4
所以该库与 header 匹配。我被困在这里,因为即使我再次 运行 我的程序,我仍然会得到完全相同的错误。我不明白为什么,库现在不应该是 1.10.4 吗?
其他地方都提示我先卸载,再重装。如果我卸载,我会得到我记下的第一个错误。当我重新安装时,循环再次开始。任何帮助将不胜感激。
你有没有试过 运行 使用 hdf5=1.10.5
conda install -c anaconda hdf5=1.10.5
而不是使用 hdf5=1.10.4?
您在 conda 环境中安装了 1.10.4 hdf5 库,Tensorflow 的某些依赖项具有较新的 hdf5 1.10.5 头文件。
尝试将您的 conda hdf5 库更新到更新的 1.10.5 或者使用命令:
set HDF5_DISABLE_VERSION_CHECK=2
这应该会禁用警告但不提供正确执行的任何保证,因此最好将 hdf5 库更新为相同版本 1.10.5.
如果这还不够,请尝试此解决方法:
首先,尝试删除 h5py 2.10.0 版本的更新,将其还原为原始版本
通过以下方式将 hdf5 升级到 1.10.5 版本:
conda install -c anaconda hdf5=1.10.5
并卸载一个double(如果你安装了double h5py)通过以下方式安装h5py:
conda uninstall h5py
pip uninstall h5py
如果只有一个就卸载
最后通过
再次升级到hdf5 2.10.0版本
conda install -c conda-forge h5py
希望对您有所帮助。
我已经创建了一个 CNN 模型并尝试将其保存为 .h5 文件,然后加载该模型。我在 Anaconda 的虚拟环境中工作。有趣的是,我可以在虚拟环境中的 Jupyter Notebook 中毫无问题地做任何事情。但是,当我在终端中尝试 运行ning 时(加载模型,然后对其进行评估),它不起作用。我有一组交替错误,这些错误在网络上有解决方案,但这些解决方案要么导致死胡同,要么导致其他错误。
第一个错误:
Traceback (most recent call last):
File "MNIST.py", line 64, in <module>
main()
File "MNIST.py", line 62, in main
evaluate_model()
File "MNIST.py", line 54, in evaluate_model
model = models.load_model('final_model.h5')
File "C:\Users\Josh Cruz\Documents\.conda\envs\tensorflow\lib\site-packages\keras\engine\saving.py", line 492, in load_wrapper
return load_function(*args, **kwargs)
File "C:\Users\Josh Cruz\Documents\.conda\envs\tensorflow\lib\site-packages\keras\engine\saving.py", line 582, in load_model
if H5Dict.is_supported_type(filepath):
File "C:\Users\Josh Cruz\Documents\.conda\envs\tensorflow\lib\site-packages\keras\utils\io_utils.py", line 209, in is_supported_type
isinstance(path, h5py.Group) or
AttributeError: module 'h5py' has no attribute 'Group'
我还没有找到修复 Attribute Error: module 'h5py' has no attribute 'Group'
的特定修复程序,但我确实找到了 similar issues online,其解决方案建议我应该使用 conda install -c conda-forge h5py
将 h5py 更新到 2.10.0。这对我来说很有意义,因为组似乎是 2.10.0 h5py 文档的一部分。
安装后出现:
The following packages will be downloaded:
package | build
---------------------------|-----------------
h5py-2.9.0 |nompi_py36h9dfa0df_1103 909 KB conda-forge
------------------------------------------------------------
Total: 909 KB
The following NEW packages will be INSTALLED:
h5py conda-forge/win-64::h5py-2.9.0-nompi_py36h9dfa0df_1103
The following packages will be SUPERSEDED by a higher-priority channel:
certifi pkgs/main::certifi-2019.11.28-py36_1 --> conda-forge::certifi-2019.11.28-
py36h9f0ad1d_1
我很困惑,因为我以为我安装的是 2.10.0 版本。我还是安装了,尝试 re-run 我的程序并得到一个全新的错误:
Headers are 1.10.4, library is 1.10.5
SUMMARY OF THE HDF5 CONFIGURATION
=================================
General Information:
-------------------
HDF5 Version: 1.10.5
Configured on: 2019-03-04
Configured by: Visual Studio 14 2015 Win64
Host system: Windows-10.0.17763
Uname information: Windows
Byte sex: little-endian
Installation point: C:/Program Files/HDF5
为了space,我没有把整个错误都包括进去,但是整个错误可以在this question. The suggestion there is to do pip install h5py --upgrade --no-dependencies --force
, but doing that leads to the same error. Another source (which I can't find right now), says there might be issues juggling both installs of pip and conda, so I run pip uninstall h5py
, and the error persists. Then, using a suggestion here中找到,我运行conda install -c anaconda hdf5=1.10.4
所以该库与 header 匹配。我被困在这里,因为即使我再次 运行 我的程序,我仍然会得到完全相同的错误。我不明白为什么,库现在不应该是 1.10.4 吗?
其他地方都提示我先卸载,再重装。如果我卸载,我会得到我记下的第一个错误。当我重新安装时,循环再次开始。任何帮助将不胜感激。
你有没有试过 运行 使用 hdf5=1.10.5
conda install -c anaconda hdf5=1.10.5
而不是使用 hdf5=1.10.4?
您在 conda 环境中安装了 1.10.4 hdf5 库,Tensorflow 的某些依赖项具有较新的 hdf5 1.10.5 头文件。
尝试将您的 conda hdf5 库更新到更新的 1.10.5 或者使用命令:
set HDF5_DISABLE_VERSION_CHECK=2
这应该会禁用警告但不提供正确执行的任何保证,因此最好将 hdf5 库更新为相同版本 1.10.5.
如果这还不够,请尝试此解决方法:
首先,尝试删除 h5py 2.10.0 版本的更新,将其还原为原始版本
通过以下方式将 hdf5 升级到 1.10.5 版本:
conda install -c anaconda hdf5=1.10.5
并卸载一个double(如果你安装了double h5py)通过以下方式安装h5py:
conda uninstall h5py
pip uninstall h5py
如果只有一个就卸载
最后通过
再次升级到hdf5 2.10.0版本conda install -c conda-forge h5py
希望对您有所帮助。