无法加载keras模型

时间:2018-05-14 08:19:07

标签: python machine-learning keras

我以前训练并保存了神经网络的keras模型,但每当我尝试加载它时,我都会收到此错误。

Traceback (most recent call last):
File "<input>", line 1, in <module>
  File "C:\Users\gio-c\PycharmProjects\NN\venv\lib\site-packages\keras\models.py", line 260, in load_model
    f = h5py.File(filepath, mode='r')
  File "C:\Users\gio-c\PycharmProjects\NN\venv\lib\site-packages\h5py\_hl\files.py", line 269, in __init__
    self._swmr_mode = True
  File "C:\Users\gio-c\PycharmProjects\NN\venv\lib\site-packages\h5py\_hl\files.py", line 99, in make_fid
    else:
  File "h5py\_objects.pyx", line 54, in h5py._objects.with_phil.wrapper
  File "h5py\_objects.pyx", line 55, in h5py._objects.with_phil.wrapper
  File "h5py\h5f.pyx", line 78, in h5py.h5f.open
OSError: Unable to open file (file signature not found)

在代码中,我只是加载keras并导入文件。 我已经尝试重新创建该文件,但没有任何反应。 关于如何解决问题的任何想法?

1 个答案:

答案 0 :(得分:0)

您的* .h5文件格式可能不正确或未被h5py识别