我想在一个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