遇到的問題:
今天在學習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(),問題解決,可以正常讀取保存的文件