TensorFlow2学习十之参数提取

提取可训练参数

model.trainable_variables 返回模型中可训练的参数

设置print输出格式

np.set_printoptions(threshold=超过多少省略显示) # 设置打印效果

np.set_printoptions(threshold=np.inf) # np.inf表示无限大

print(model.trainable_variables)
file = open('./weights.txt', 'w')
for v in model.trainable_variables:
	file.write(str(v.name) + '\n')
	file.write(str(v.shape) + '\n')
	file.write(str(v.numpy()) + '\n')
file.close()

猜你喜欢

转载自blog.csdn.net/qq_41754907/article/details/113076273