【发布时间】:2017-08-26 05:51:55
【问题描述】:
我正在尝试使用 h5py 将 numpy 数组保存在 HDF 文件中,如下所示:
with h5py.File("mfcc_aligned.hdf", "w") as aligned_f:
# do stuff to create two numpy arrays, training_X and training_Y
print(len(training_X)) # this returns the number of elements I expect in the the numpy arr
aligned_f.create_dataset("train_X", data=training_X)
aligned_f.create_dataset("train_Y", data=training_Y)
# if I add a line here to access the datasets I just created, I see that aligned_f does indeed have two keys train_X and train_Y with the shapes I expect
但是,当程序结束并检查文件mfcc_aligned.hdf 时,它正好是 800 字节(比我预期的要小得多),并且没有密钥。我不知道这里发生了什么。
提前感谢您的任何见解!
【问题讨论】:
-
你试过了吗:with h5py.File('mfcc_aligned.hdf', 'r') as hf: print = hf['train_X'][:]