有时候使用ckpt时需要查看内部tensor name和值时,需要打印输出,ckpt文件的话放到checkpoint,如果三个文件,只添加文件名,类型忽略。
import os
from tensorflow.python import pywrap_tensorflow
checkpoint_path = os.path.join(model_dir, "print——model.ckpt")
# Read data from checkpoint file
reader = pywrap_tensorflow.NewCheckpointReader(checkpoint_path)
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))
可以显示ckpt中的tensor名字和值,当然也可以用pycharm调试。