Keras.js编码器无法编码hdf5模型

时间:2017-12-26 10:52:53

标签: python keras

我试图在浏览器上运行keras模型。我关注的是this博客。

我有两个名为model.hdf5model.json的模型文件。我还从github repository下载了两个python文件encoder.pymodel_pb2.py,需要将权重与其他数据分开。我跑的时候

python encoder.py ./model.hdf5

我收到以下错误。

from ._conv import register_converters as _register_converters
Traceback (most recent call last):
  File "encoder.py", line 120, in <module>
    encoder.serialize()
  File "encoder.py", line 68, in serialize
    self.model.model_config = hdf5_file.attrs['model_config']
  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 "/usr/local/lib/python2.7/dist-packages/h5py/_hl/attrs.py", line 60, in __getitem__
    attr = h5a.open(self._id, self._e(name))
  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/h5a.pyx", line 77, in h5py.h5a.open
KeyError: "Can't open attribute (can't locate attribute: 'model_config')"

我用Google搜索并找不到任何解决方案。 为什么我收到此错误?提前谢谢。

1 个答案:

答案 0 :(得分:0)

解决此问题使用KerasJs V0.3(download from here

这个问题在github(https://github.com/transcranial/keras-js/issues/87

中讨论和解决