读取H5文件

import h5py  #导入工具包
import numpy as np
#打开文件
f = h5py.File(‘c:\lstm_248_114_0.33_0.36.h5′,’r’)
#遍历文件中的一级组
for group in f.keys():
    print(group)
    #根据一级组名获得其下面的组
    group_read = f[group]
    #遍历该一级组下面的子组
    for subgroup in group_read.keys():
        print(subgroup)     
        #根据一级组和二级组名获取其下面的dataset          
        dset_read = f[group+’/’+subgroup]                           
        #遍历该子组下所有的dataset
        for dset in dset_read.keys():
            #获取dataset数据
            dset1 = f[group+’/’+subgroup+’/’+dset]
            print(dset1.name)
            data = np.array(dset1)
            print(“data.shape=”,data.shape)
#            print(“data=”,data)
#             x = data[…,0]
#             y = data[…,1]  

 

结合

https://blog.csdn.net/qq_33302076/article/details/86496445?utm_medium=distribute.pc_aggpage_search_result.none-task-blog-2~all~first_rank_v2~rank_v25-5-86496445.nonecase&utm_term=h5%E6%96%87%E4%BB%B6%E7%9A%84%E6%89%93%E5%BC%80%E6%96%B9%E5%BC%8F

https://blog.csdn.net/y_f_raquelle/article/details/84134851?utm_medium=distribute.pc_aggpage_search_result.none-task-blog-2~all~first_rank_v2~rank_v25-13-84134851.nonecase&utm_term=h5%E6%96%87%E4%BB%B6%E7%9A%84%E6%89%93%E5%BC%80%E6%96%B9%E5%BC%8F

    原文作者:火星种萝卜
    原文地址: https://blog.csdn.net/studyvcmfc/article/details/108175816
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞