最近做深度學習需要讀取hdf5檔案,我讀取的檔案,我利用的github上分享源代碼生成了hdf5檔案,位址為https://github.com/tomrunia/TF_FeatureExtraction
我生成的是vgg16_features.h5
然後我讀取的代碼為:
#coding=utf-8
import h5py
eventNumber = 5
vgg_feature = h5py.File('vgg16_features.h5','r')
# keys=vgg_feature.keys() #可以檢視所有的主鍵
# values=vgg_feature.values()
# print(keys)
# print(values)
# print(vgg_feature.items())
filenames = vgg_feature['filenames']
vgg_16=vgg_feature['vgg_16']
for i in xrange(len(filenames)):
arr1ev = filenames[i]
image_feature=vgg_16["fc7"][i]
print(arr1ev)
print(image_feature)
vgg_feature.close()
參考文獻
[1].Datasets.http://docs.h5py.org/en/latest/high/dataset.html [2].How to access HDF5 data from Python.https://confluence.slac.stanford.edu/display/PSDM/How+to+access+HDF5+data+from+Python [3].Python 讀取HDF5檔案.http://blog.csdn.net/lsh894609937/article/details/77018622