# define model
model.load_weights(modelname)
for lay in model.layers:
with open(weights_file,'a+', encoding='utf-8') as f:
f.write(lay.name + '\n')
weights = lay.get_weights()
for i in range(len(weights)):
f.write('shape:' + str(weights[i].shape) + '\n')
f.write(str(weights[i]) + '\n')
如果遇到array显示不全的情况,只需添加np.set_printoptions(threshold=np.inf)即可