[英]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.