遇到的问题:
今天在学习tensorflow的模型保存和载入中出现以下BUG
NotFoundError: Restoring from checkpoint failed. This is most likely
due to a Variable name or other graph key that is missing from the
checkpoint. Please ensure that you have not altered the graph expected
based on the checkpoint. Original error:
Key bias_2 not found in checkpoint
解决过程:经过自己的排查后发现在代码中少了一句
tf.reset_default_graph()
这条语句用来重置图,可能是因为图没有重置,导致检查点找不到所以导入不了模型
实际操作:在有关图的变量定义前加入tf.reset_default_graph(),问题解决,可以正常读取保存的文件