在使用pre-train model时候,我们需要restore variables from checkpoint files.
经常出现在checkpoint 中找不到”Tensor name not found”.
这时候需要查看一下ckpt中到底有哪些变量
import os
from tensorflow.python import pywrap_tensorflow
model_dir="./"
checkpoint_path = os.path.join(model_dir, "resnet_v2_152.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))
转自:http://blog.youkuaiyun.com/noirblack/article/details/71430790

本文介绍如何在TensorFlow中从预训练模型的检查点文件中恢复变量,通过使用pywrap_tensorflow模块的NewCheckpointReader类读取变量名称和形状,帮助解决在加载模型时遇到的Tensor name not found问题。
5270

被折叠的 条评论
为什么被折叠?



