2016-03-24 40 views
1

Çok boyutlu bir dizinin bir boyutunun boyutu sabitlenmediğinde, HDF5 veri kümesi nasıl oluşturulur? Aşağıdaki oyuncak kodunu denedim, ama burada bazı noktalarda eksik gözüküyor.Python'da bir HDF5 Veri Kümesi oluştururken değişken boyuttaki diziyle nasıl baş edilir?

Çok basit
import numpy as np 

import h5py 


Polyline=h5py.special_dtype(vlen=np.float32) 

f=h5py.File('dataset.hdf5', mode='w') 

var_features=f.create_dataset('var_features', (10,), dtype=Polyline) 

features = np.empty(shape=(10,), dtype=Polyline) 

for i in range(10): 

    a=10+i*2 
    features[i]=np.arange(a).reshape(a/2,2) 

var_features[...]=features 

print features[0].shape 

print var_features[0].shape 

cevap

0

, sadece bir ya da daha fazla None değerlerle maxsize özelliği olan veri kümesi oluşturmak. Böyle

şey:

import h5py 
import numpy as np 

fff = h5py.File('test1.h5','w') 
fff.create_dataset('test_resize',(100,100),maxshape=(None,None),chunks=(10,10)) 
fff['test_resize'][:] = np.random.random((100,100)) 
fff.flush() 
fff['test_resize'].resize((150,100)) 
fff['test_resize'][100:150,:] = np.ones((50,100)) 
fff.close() 
İlgili konular