TensorFlow 输出checkpoint 中的变量名与变量值

import os
from tensorflow.python import pywrap_tensorflow
model_dir="/xxxxxxxxx/model.ckpt" #checkpoint的文件位置
# Read data from checkpoint file
reader = pywrap_tensorflow.NewCheckpointReader(model_dir)
var_to_shape_map = reader.get_variable_to_shape_map()
# Print tensor name and values
for key in var_to_shape_map:
    print("tensor_name: ", key)  #输出变量名
    print(reader.get_tensor(key))   #输出变量值

输出结果:
这里只输出了变量名

猜你喜欢

转载自blog.csdn.net/qq_32799915/article/details/80312928