I'm trying to run code from here in Google Colab code I run
But on second line of
hf = h5py.File('data_1.h5', 'w')
hf.create_dataset('dataset_1', data=x)
I get following error:
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
Why does it appear? What's the root cause? Any ideas on how to fix it?
What I see in x is
[[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.],
.......
The fix for code is to keep the x like this:
hf.create_dataset('dataset_1', (len(x),), dtype=dt)
hf['dataset_1'][...] = x
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.