原文链接: python h5py(h5文件) 文件内容读取
上一篇: Python 键盘按键监听 截取全屏 百度ai通用文字识别
下一篇: 数字中1的个数 循环判断 位与 查表法 二次查表法
使用递归函数显示文件数据结构
如果有value属性,表示该数据为值,打印出来,如果没有则表示数据为组group,继续递归显示
import h5py
file = h5py.File('S1aire_test_T01.h5')
def show(data):
print('name ---', data.name)
if 'value' in dir(data):
# 有值的话直接打出
# print(data.shape)
print(data.value)
else:
# 是一个group的话则继续深入
for k in data:
show(data[k])
show(file)
name 表示数据所在的层级,根为/
vgg19 文章来源:https://www.toymoban.com/news/detail-406110.html
没有输出数值。。。太多了。。。。只输出形状 文章来源地址https://www.toymoban.com/news/detail-406110.html
name --- /
name --- /layer_0
name --- /layer_1
name --- /layer_1/param_0
(64, 3, 3, 3)
name --- /layer_1/param_1
(64,)
name --- /layer_10
name --- /layer_11
name --- /layer_11/param_0
(256, 128, 3, 3)
name --- /layer_11/param_1
(256,)
name --- /layer_12
name --- /layer_13
name --- /layer_13/param_0
(256, 256, 3, 3)
name --- /layer_13/param_1
(256,)
name --- /layer_14
name --- /layer_15
name --- /layer_15/param_0
(256, 256, 3, 3)
name --- /layer_15/param_1
(256,)
name --- /layer_16
name --- /layer_17
name --- /layer_17/param_0
(256, 256, 3, 3)
name --- /layer_17/param_1
(256,)
name --- /layer_18
name --- /layer_19
name --- /layer_2
name --- /layer_20
name --- /layer_20/param_0
(512, 256, 3, 3)
name --- /layer_20/param_1
(512,)
name --- /layer_21
name --- /layer_22
name --- /layer_22/param_0
(512, 512, 3, 3)
name --- /layer_22/param_1
(512,)
name --- /layer_23
name --- /layer_24
name --- /layer_24/param_0
(512, 512, 3, 3)
name --- /layer_24/param_1
(512,)
name --- /layer_25
name --- /layer_26
name --- /layer_26/param_0
(512, 512, 3, 3)
name --- /layer_26/param_1
(512,)
name --- /layer_27
name --- /layer_28
name --- /layer_29
name --- /layer_29/param_0
(512, 512, 3, 3)
name --- /layer_29/param_1
(512,)
name --- /layer_3
name --- /layer_3/param_0
(64, 64, 3, 3)
name --- /layer_3/param_1
(64,)
name --- /layer_30
name --- /layer_31
name --- /layer_31/param_0
(512, 512, 3, 3)
name --- /layer_31/param_1
(512,)
name --- /layer_32
name --- /layer_33
name --- /layer_33/param_0
(512, 512, 3, 3)
name --- /layer_33/param_1
(512,)
name --- /layer_34
name --- /layer_35
name --- /layer_35/param_0
(512, 512, 3, 3)
name --- /layer_35/param_1
(512,)
name --- /layer_36
name --- /layer_37
name --- /layer_38
name --- /layer_38/param_0
(25088, 4096)
name --- /layer_38/param_1
(4096,)
name --- /layer_39
name --- /layer_4
name --- /layer_40
name --- /layer_40/param_0
(4096, 4096)
name --- /layer_40/param_1
(4096,)
name --- /layer_41
name --- /layer_42
name --- /layer_42/param_0
(4096, 1000)
name --- /layer_42/param_1
(1000,)
name --- /layer_5
name --- /layer_6
name --- /layer_6/param_0
(128, 64, 3, 3)
name --- /layer_6/param_1
(128,)
name --- /layer_7
name --- /layer_8
name --- /layer_8/param_0
(128, 128, 3, 3)
name --- /layer_8/param_1
(128,)
name --- /layer_9
到了这里,关于python h5py(h5文件) 文件内容读取的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!