NotFoundError: Restoring from checkpoint failed. 解决

遇到的问题:
今天在学习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(),问题解决,可以正常读取保存的文件
在这里插入图片描述

发布了36 篇原创文章 · 获赞 12 · 访问量 5080
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章