以下代码是我保存numpy数组的方式,保存后大约为27GB。图片数据超过200K,每种形状为(224,224,3)
hf = h5py.File('cropped data/features_train.h5','w')
for i,each in enumerate(features_train):
hf.create_dataset(str(i),data=each)
hf.close()
这是我用来加载数据的方法,需要花费数小时才能加载。
features_train = np.zeros(shape=(1,3))
hf = h5py.File('cropped data/features_train.h5','r')
for key in hf.keys():
x = hf.get(key)
x = np.array(x)
features_train = np.append(features_train,np.array([x]),axis=0)
hf.close()
那么,对于如此大的数据量,是否有人有更好的解决方案?