13

h5pyPython ライブラリを使用して HDF5 配列のサイズを変更するにはどうすればよいですか?

メソッドを使用して、に設定し.resizeた配列で試しました。残念ながら、私はまだ何かが欠けています。chunksTrue

In [1]: import h5py

In [2]: f = h5py.File('foo.hdf5', 'w')

In [3]: d = f.create_dataset('data', (3, 3), dtype='i8', chunks=True)

In [4]: d.resize((6, 3))
/home/mrocklin/Software/anaconda/lib/python2.7/site-packages/h5py/_hl/dataset.pyc in resize(self, size, axis)
--> 277         self.id.set_extent(size)
ValueError: unable to set extend dataset (Dataset: Unable to initialize object)

In [11]: h5py.__version__ 
Out[11]: '2.2.1'
4

2 に答える 2

14

Oren が述べたように、後で配列のサイズを変更する場合はmaxshape、作成時に使用する必要があります。datasetディメンションを に設定すると、None後でそのディメンションを 2**64 (h5 の制限) までサイズ変更できます。

In [1]: import h5py

In [2]: f = h5py.File('foo.hdf5', 'w')

In [3]: d = f.create_dataset('data', (3, 3), maxshape=(None, 3), dtype='i8', chunks=True)

In [4]: d.resize((6, 3))

In [5]: h5py.__version__
Out[5]: '2.2.1'

詳細については、ドキュメントを参照してください。

于 2014-10-06T00:19:51.550 に答える
3

この行を変更する必要があります:

d = f.create_dataset('data', (3, 3), dtype='i8', chunks=True)

d = f.create_dataset('data', (3, 3), maxshape=(?, ?), dtype='i8', chunks=True) 

d.resize((?, ?))

?を変更します。どのようなサイズでも ( Noneに設定することもできます)

ここを読む: http://docs.h5py.org/en/latest/high/dataset.html#resizable-datasets

于 2014-05-01T20:00:31.653 に答える