各位小伙伴大家好呀~
今天给大家分享一下深度学习中后缀为.h5文件怎么查看里面的内容:
使用到的软件PyCharm专业版(社区版也是可以哒,只不过我是使用的这个软件)
大家打开PyCharm,新建一个Python文件:
import h5py
file_path = '你的.h5文件路径(建议大家使用绝对路径)'
f = h5py.File(file_path, 'r')
print("Objects in the HDF5 file:")
for name in f:
print(name)
f.close()
然后大家就可以在Python Console中看到结果啦~~
就像这样的形式:
当然,刚才的代码并不能看到里面的内容,加下来的代码,可以看到文件中的内容:
import h5py
file_path = '你的文件的位置(建议使用绝对路径)'
f = h5py.File(file_path, 'r')
print("Objects in the HDF5 file:")
for name in f:
print(name)
for dataset_name in f[name]:
dataset = f[name][dataset_name]
print(dataset_name, dataset.shape) # 打印数据集名称和形状
# 进一步操作和查看数据集内容
f.close()
运行的结果:
大家赶快去试试吧!!!