我想在一個HDF文件保存numpy的陣列h5py如下妥善保存:HDF文件不h5py
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字節(比我預期的小得多),並且沒有密鑰。我對這裏發生的事情感到不知所措。
在此先感謝您的任何見解!
做了嘗試:用h5py.File('mfcc_aligned。 hdf','r')爲hf: print = hf ['train_X'] [:] – user1269942