如何打印 Keras weight.h5 文件的权重?

How can I print the weights of a Keras weight.h5 file?

我有一个 Keras 生成的 h5 文件,我想在 Python 中打印权重值。谢谢

我做了(因为我自己的问题)

import h5py
keys = []
with h5py.File("The-subnet-weight.h5",'r') as f: # open file
    f.visit(keys.append) # append all keys to list
    for key in keys:
            if ':' in key: # contains data if ':' in key
                print(f[key].name)

import numpy as np  #Define the info to extract
f = h5py.File("The-subnet-weight.h5",'r')
group = f[key]
b4 = group['/dense_5/dense_5/bias:0'].value
k4= group['/dense_5/dense_5/kernel:0'].value
K4=np.transpose(np.array(k4)) #Process
   
f.close() #Close key

from numpy import savetxt #Save as human readable
savetxt('b4.csv', b4, delimiter=',')
savetxt('w4.csv', K4, delimiter=',')