解決tensorflow測試模型時NotFoundError錯誤的問題
更新時間:2018年07月26日 10:55:23 作者:John_kai
今天小編就為大家分享一篇解決tensorflow測試模型時NotFoundError錯誤的問題,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧
錯誤代碼如下:
NotFoundError (see above for traceback): Unsuccessful TensorSliceReader constructor: Failed to find any matching files for xxx ……
經(jīng)查資料分析,錯誤原因可能出在加載模型時的路徑問題。我采用的加載模型方法:
with tf.Session() as sess: print("Reading checkpoints...") ckpt = tf.train.get_checkpoint_state(logs_train_dir) if ckpt and ckpt.model_checkpoint_path: global_step = ckpt.model_checkpoint_path.split('/') [-1].split('-')[-1] saver.restore(sess, ckpt.model_checkpoint_path) print('Loading success, global_step is %s' % global_step) else: print('No checkpoint file found')
在保存模型時,采用的方法為
saver = tf.train.Saver() …… …… …… if step % 1000 == 0 or (step + 1) == MAX_STEP: checkpoint_path = os.path.join(logs_train_dir, './model.ckpt') saver.save(sess, checkpoint_path, global_step=step)
注意代碼塊中的./model.ckpt,這是關鍵,原來為model.ckpt就會報錯。如果在加載模型時采用直接加載模型文件的方法,則:
改之前代碼:
saver.restore(sess,'model.ckpt')
改之后的代碼:
saver.restore(sess,'./model.ckpt')
我的改之后是沒有什么問題了,如果這種方法不能解決你的問題,再查資料解決吧
以上這篇解決tensorflow測試模型時NotFoundError錯誤的問題就是小編分享給大家的全部內(nèi)容了,希望能給大家一個參考,也希望大家多多支持腳本之家。
相關文章
python語言線程標準庫threading.local解讀總結
在本篇文章里我們給各位整理了一篇關于python threading.local源碼解讀的相關文章知識點,有需要的朋友們可以學習下。2019-11-11python讀取excel數(shù)據(jù)并且畫圖的實現(xiàn)示例
這篇文章主要介紹了python讀取excel數(shù)據(jù)并且畫圖的實現(xiàn)示例,幫助大家更好的理解和使用python,感興趣的朋友可以了解下2021-02-02利用Python操作MongoDB數(shù)據(jù)庫的詳細指南
MongoDB是由C++語言編寫的非關系型數(shù)據(jù)庫,是一個基于分布式文件存儲的開源數(shù)據(jù)庫系統(tǒng),其內(nèi)容存儲形式類似JSON對象,下面這篇文章主要給大家介紹了關于利用Python操作MongoDB數(shù)據(jù)庫的相關資料,需要的朋友可以參考下2022-06-06