【问题标题】:Python layer can't read hdf5 file in caffe frameworkPython层无法读取caffe框架中的hdf5文件
【发布时间】:2016-04-21 02:09:43
【问题描述】:

我为 caffe 编写了 python 层,它可以读取 hdf5 并满足我的一些操作需求。但是在 python 设置方法中打开和读取 hdf5 文件时我遇到了一些问题。这里是。 当我使用带有 设置代码:

def setup(self, bottom, top):
    h5file = tables.open_file("/home/titan/models/hdf5/train_small.h5", driver="H5FD_CORE")

运行网络时出现此错误:

Traceback (most recent call last):
  File "/home/titan/scripts/python_layers/pydata_hdf5.py", line 37, in setup
    h5file = tables.open_file("/home/titan/models/hdf5/train_small.h5", driver="H5FD_CORE")
  File "/home/titan/anaconda/lib/python2.7/site-packages/tables/file.py", line 318, in open_file
    return File(filename, mode, title, root_uep, filters, **kwargs)
  File "/home/titan/anaconda/lib/python2.7/site-packages/tables/file.py", line 784, in __init__
    self._g_new(filename, mode, **params)
  File "tables/hdf5extension.pyx", line 465, in tables.hdf5extension.File._g_new (tables/hdf5extension.c:4872)
tables.exceptions.HDF5ExtError: HDF5 error back trace

  File "../../../src/H5FDcore.c", line 273, in H5Pset_fapl_core
    not a file access property list
  File "../../../src/H5Pint.c", line 3371, in H5P_object_verify
    property list is not a member of the class
  File "../../../src/H5Pint.c", line 3321, in H5P_isa_class
    not a property list

End of HDF5 error back trace

当我使用 h5py 时

def setup(self, bottom, top):
    self.data = h5py.File('/home/titan/models/hdf5_nose_mouth/train_small.h5', 'r')

我有同样的错误:

Traceback (most recent call last):
  File "/home/titan/scripts/python_layers/pydata_hdf5.py", line 11, in <module>
    import h5py
  File "/home/titan/anaconda/lib/python2.7/site-packages/h5py/__init__.py", line 31, in <module>
    from .highlevel import *
  File "/home/titan/anaconda/lib/python2.7/site-packages/h5py/highlevel.py", line 13, in <module>
    from ._hl.base import is_hdf5, HLObject
  File "/home/titan/anaconda/lib/python2.7/site-packages/h5py/_hl/base.py", line 78, in <module>
    dlapl = default_lapl()
  File "/home/titan/anaconda/lib/python2.7/site-packages/h5py/_hl/base.py", line 65, in default_lapl
    lapl = h5p.create(h5p.LINK_ACCESS)
  File "h5py/_objects.pyx", line 54, in h5py._objects.with_phil.wrapper (-------src-dir-------/h5py/_objects.c:2458)
  File "h5py/_objects.pyx", line 55, in h5py._objects.with_phil.wrapper (-------src-dir-------/h5py/_objects.c:2415)
  File "h5py/h5p.pyx", line 130, in h5py.h5p.create (-------src-dir-------/h5py/h5p.c:2491)
ValueError: Not a property list class (Not a property list class)

当我使用 deepdish 时:

def setup(self, bottom, top):
    self.data = dd.io.load('/home/titan/models/hdf5/train_smallest.h5')

我也有错误:

Traceback (most recent call last):
  File "/home/titan/scripts/python_layers/pydata_hdf5.py", line 36, in setup
    self.data = dd.io.load('/home/titan/models/hdf5/train_smallest.h5')
  File "/home/titan/anaconda/lib/python2.7/site-packages/deepdish/io/hdf5io.py", line 476, in load
    with tables.open_file(path, mode='r') as h5file:
  File "/home/titan/anaconda/lib/python2.7/site-packages/tables/file.py", line 318, in open_file
    return File(filename, mode, title, root_uep, filters, **kwargs)
  File "/home/titan/anaconda/lib/python2.7/site-packages/tables/file.py", line 784, in __init__
    self._g_new(filename, mode, **params)
  File "tables/hdf5extension.pyx", line 488, in tables.hdf5extension.File._g_new (tables/hdf5extension.c:5081)
tables.exceptions.HDF5ExtError: HDF5 error back trace

  File "../../../src/H5F.c", line 1582, in H5Fopen
    not file access property list
  File "../../../src/H5Pint.c", line 3321, in H5P_isa_class
    not a property list

End of HDF5 error back trace

但是当我只阅读 *.txt 文件时,一切正常。我也可以从控制台读取这个文件并在 caffe 的 hdf5 层中使用它。请帮助我,如何从 python 层读取 hdf5 文件?

【问题讨论】:

  • 这很奇怪。 h5ls 在这个文件上输出什么?
  • 当我成功时:titan@titan:~/models/hdf5$ h5ls train_small.h5 data Dataset {100, 3, 64, 64} label Dataset {100, 4}
  • 很奇怪。我提出了一个解决方法:如果您可以在"HDF5Data" 层中读取文件,为什么不在caffe HDF5data 层中读取它并且只添加一个python 层进行操作?
  • 因为我需要访问文件中的所有行。如果我将在 HDF5Data 之后使用 pylayer,我只能使用 prew 层(HDF5Data)中的 blob。

标签: python hdf5 caffe h5py pycaffe


【解决方案1】:

尝试安装另一个版本的 h5py。我刚刚解决了它:

pip install h5py==prev_version

我猜这与链接有关,但知道哪个是导致此问题的确切原因会很有趣。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-07-03
    • 2019-11-07
    • 2017-11-26
    • 2018-04-08
    • 2015-03-26
    • 1970-01-01
    • 2016-02-11
    相关资源
    最近更新 更多