h5py:切片h5py数据时出错

2024-09-27 21:32:55 发布

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

[更新:问题已解决。解决方案见结尾]

我试图分割一个h5py数据集,但这里只得到一个错误

In[76]: dataset['traindata']
Out[76]: <HDF5 dataset "traindata": shape (100, 50), type "<f4">

In[76]: dataset['traindata'][0, 0:10]
---------------------------------------------------------------------------
SystemError                               Traceback (most recent call last)
<ipython-input-77-4033a3d41a81> in <module>()
----> 1 dataset['traindata'][0, 0:10]

E:\Anaconda\lib\site-packages\h5py\_hl\dataset.pyc in __getitem__(self, args)
    437         mspace = h5s.create_simple(mshape)
    438         fspace = selection._id
--> 439         self.id.read(mspace, fspace, arr, mtype)
    440 
    441         # Patch up the output for NumPy

SystemError: error return without exception set

但当我将同一组中的另一个数据集切片时,它似乎工作得很好

^{pr2}$

我不太明白dataset['trainlabel']出了什么问题。在

以前有人碰到过这个吗?谢谢。在

p.S.dataset是从v7.3.mat文件中读取的。”traindata”最初是一个单精度矩阵,而“trainlabel”是.mat文件中的int32向量。在

[解决方案:使用http://www.lfd.uci.edu/~gohlke/pythonlibs/#h5py提供的预构建版本覆盖现有的h5py lib(与Anaconda一起提供)。在


Tags: 数据inselfidlibanaconda解决方案dataset

热门问题