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

2024-10-02 22:33:20 发布

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

我试图在Google Colabcode I run中从这里运行代码

但是在第二行

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.],
            .......

Tags: run代码inpydatacreategoogledataset