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
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章