说明
1、hdf5不支持用其他浏览器打开,建议写一个代码来进行读取。
2、读取HDF5文件中的所有数据集,然后传输到路径。
实例
# 读取HDF5文件中的所有数据集 def traverse_datasets(hdf_file): import h5py def h5py_dataset_iterator(g, prefix=''): for key in g.keys(): item = g[key] path = '{}/{}'.format(prefix, key) if isinstance(item, h5py.Dataset): # test for dataset yield (path, item) elif isinstance(item, h5py.Group): # test for group (go down) yield from h5py_dataset_iterator(item, path) with h5py.File(hdf_file, 'r') as f: for (path, dset) in h5py_dataset_iterator(f): print(path, dset) return None # 传入路径即可 traverse_datasets('datasets/train_catvnoncat.h5')
以上就是python查看hdf5文件的方法,希望对大家有所帮助。更多Python学习指路:
本文教程操作环境:windows7系统、Python 3.9.1,DELL G3电脑。
Copyright © 2019- net188.cn 版权所有 湘ICP备2022005869号-2
违法及侵权请联系:TEL:199 1889 7713 E-MAIL:2724546146@qq.com
本站由北京市万商天勤律师事务所王兴未律师提供法律服务