最近做深度学习需要读取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