Python层无法读取caffe fram中的hdf5文件

2024-07-07 07:43:31 发布

您现在位置:Python中文网/ 问答频道 /正文

我为caffe编写python层,它可以读取hdf5,但需要一些操作。但在python设置方法中打开并读取hdf5文件时,我遇到了一些问题。给你。 当我用桌子和 设置中的代码:

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

运行网络时出现以下错误:

^{pr2}$

当我用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文件?在


Tags: inpyselfhometableslibpackagesline