繁体   English   中英

使用 h5py python 创建数据集时出错

[英]Error when creating dataset with h5py python

我正在尝试在我运行的Google Colab 代码中从这里运行代码

但是在第二行

hf = h5py.File('data_1.h5', 'w')

hf.create_dataset('dataset_1', data=x) 

我收到以下错误:

    116         else:
    117             dtype = numpy.dtype(dtype)
    --> 118         tid = h5t.py_create(dtype, logical=1)    
    119     
    120     # Legacy
    h5py/h5t.pyx in h5py.h5t.py_create()
    h5py/h5t.pyx in h5py.h5t.py_create()
    h5py/h5t.pyx in h5py.h5t.py_create()

    TypeError: Object dtype dtype('O') has no native HDF5 equivalent

为什么会出现? 根本原因是什么? 关于如何解决它的任何想法?

我在 x 中看到的是

    [[array([[[255., 255., 255.],
            [255., 255., 255.],
            [255., 255., 255.],
            ...,
            [255., 255., 255.],
            [255., 255., 255.],
            [255., 255., 255.]],
    
           [[255., 255., 255.],
            [255., 255., 255.],
            [255., 255., 255.],
            .......

代码的修复是保持 x 像这样:

hf.create_dataset('dataset_1', (len(x),), dtype=dt)
hf['dataset_1'][...] = x

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM