解決tensorflow1.x版本加載saver.restore目錄報錯的問題
這個錯誤是最新的錯誤哈,目前只在tensorflow上的github倉庫上面有提出,所以你在百度上面找不到。
是個tensorflow的bug十天前提出的,只有g(shù)ithub倉庫上一個地方有提出。
NotFoundError (see above for traceback): Unsuccessful TensorSliceReader constructor: Failed to find any matching files for xxx
Traceback (most recent call last): File "C:\Users\Administrator\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\client\session.py", line 1022, in _do_call return fn(*args) File "C:\Users\Administrator\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\client\session.py", line 1004, in _run_fn status, run_metadata) File "C:\Users\Administrator\AppData\Local\Programs\Python\Python35\lib\contextlib.py", line 66, in __exit__ next(self.gen) File "C:\Users\Administrator\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\framework\errors_impl.py", line 466, in raise_exception_on_not_ok_status pywrap_tensorflow.TF_GetCode(status)) tensorflow.python.framework.errors_impl.NotFoundError: Unsuccessful TensorSliceReader constructor: Failed to find any matching files for D://model.ckpt [[Node: save_1/RestoreV2_10 = RestoreV2[dtypes=[DT_FLOAT], _device="/job:localhost/replica:0/task:0/cpu:0"](_recv_save_1/Const_0, save_1/RestoreV2_10/tensor_names, save_1/RestoreV2_10/shape_and_slices)]] During handling of the above exception, another exception occurred: Traceback (most recent call last): File "F:/DeepStock/DeepStock/testCapacity.py", line 77, in <module> prediction(out) File "F:/DeepStock/DeepStock/testCapacity.py", line 63, in prediction saver.restore(sess, 'D://model.ckpt') File "C:\Users\Administrator\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\training\saver.py", line 1428, in restore {self.saver_def.filename_tensor_name: save_path}) File "C:\Users\Administrator\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\client\session.py", line 767, in run run_metadata_ptr) File "C:\Users\Administrator\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\client\session.py", line 965, in _run feed_dict_string, options, run_metadata) File "C:\Users\Administrator\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\client\session.py", line 1015, in _do_run target_list, options, run_metadata) File "C:\Users\Administrator\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\client\session.py", line 1035, in _do_call raise type(e)(node_def, op, message) tensorflow.python.framework.errors_impl.NotFoundError: Unsuccessful TensorSliceReader constructor: Failed to find any matching files for D://model.ckpt [[Node: save_1/RestoreV2_10 = RestoreV2[dtypes=[DT_FLOAT], _device="/job:localhost/replica:0/task:0/cpu:0"](_recv_save_1/Const_0, save_1/RestoreV2_10/tensor_names, save_1/RestoreV2_10/shape_and_slices)]] Caused by op 'save_1/RestoreV2_10', defined at: File "F:/DeepStock/DeepStock/testCapacity.py", line 77, in <module> prediction(out) File "F:/DeepStock/DeepStock/testCapacity.py", line 60, in prediction saver = tf.train.Saver(tf.global_variables()) File "C:\Users\Administrator\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\training\saver.py", line 1040, in __init__ self.build() File "C:\Users\Administrator\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\training\saver.py", line 1070, in build restore_sequentially=self._restore_sequentially) File "C:\Users\Administrator\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\training\saver.py", line 675, in build restore_sequentially, reshape) File "C:\Users\Administrator\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\training\saver.py", line 402, in _AddRestoreOps tensors = self.restore_op(filename_tensor, saveable, preferred_shard) File "C:\Users\Administrator\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\training\saver.py", line 242, in restore_op [spec.tensor.dtype])[0]) File "C:\Users\Administrator\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\ops\gen_io_ops.py", line 668, in restore_v2 dtypes=dtypes, name=name) File "C:\Users\Administrator\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\framework\op_def_library.py", line 763, in apply_op op_def=op_def) File "C:\Users\Administrator\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\framework\ops.py", line 2327, in create_op original_op=self._default_original_op, op_def=op_def) File "C:\Users\Administrator\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\framework\ops.py", line 1226, in __init__ self._traceback = _extract_stack() NotFoundError (see above for traceback): Unsuccessful TensorSliceReader constructor: Failed to find any matching files for D://model.ckpt [[Node: save_1/RestoreV2_10 = RestoreV2[dtypes=[DT_FLOAT], _device="/job:localhost/replica:0/task:0/cpu:0"](_recv_save_1/Const_0, save_1/RestoreV2_10/tensor_names, save_1/RestoreV2_10/shape_and_slices)]]
改之前代碼:
saver.restore(sess, 'D://model.ckpt')
將前面加上個點斜杠就好了。
saver.restore(sess, 'D://./model.ckpt')
如果你目錄太復(fù)雜實在搞不明白用這個(默認加載checkout 文件中的最新的保存的數(shù)據(jù)):
module_file = tf.train.latest_checkpoint('E://deeplearning-master/deeplearning-master/tensorflow-program/save/') with tf.Session() as sess: sess.run(tf.global_variables_initializer()) if module_file is not None: saver.restore(sess, module_file)
以上這篇解決tensorflow1.x版本加載saver.restore目錄報錯的問題就是小編分享給大家的全部內(nèi)容了,希望能給大家一個參考,也希望大家多多支持腳本之家。
相關(guān)文章
Opencv中的cv2.calcHist()函數(shù)的作用及返回值說明
這篇文章主要介紹了Opencv中的cv2.calcHist()函數(shù)的作用及返回值說明,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教2022-11-11python?中collections的?deque使用詳解
這篇文章主要介紹了python中collections的deque使用詳解,deque是一個雙端隊列,如果要經(jīng)常從兩端append的數(shù)據(jù),選擇這個數(shù)據(jù)結(jié)構(gòu)就比較好了,更多相關(guān)內(nèi)容,需要的小伙伴可以參考下面文章內(nèi)容2022-09-09Python3爬蟲學(xué)習(xí)之MySQL數(shù)據(jù)庫存儲爬取的信息詳解
這篇文章主要介紹了Python3爬蟲學(xué)習(xí)之MySQL數(shù)據(jù)庫存儲爬取的信息,涉及Python3針對mysql數(shù)據(jù)庫的連接、信息存儲等相關(guān)操作技巧,需要的朋友可以參考下2018-12-12python通過設(shè)置WordCloud參數(shù)實現(xiàn)定制詞云
這篇文章主要為大家詳細介紹了python如何通過設(shè)置WordCloud參數(shù)實現(xiàn)定制詞云,文中的示例代碼講解詳細,感興趣的小伙伴可以跟隨小編一起學(xué)習(xí)一下2023-11-11Python基于codecs模塊實現(xiàn)文件讀寫案例解析
這篇文章主要介紹了Python基于codecs實現(xiàn)文件讀寫案例解析,文中通過示例代碼介紹的非常詳細,對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友可以參考下2020-05-05Python分析特征數(shù)據(jù)類別與預(yù)處理方法速學(xué)
這篇文章主要為大家介紹了Python分析特征數(shù)據(jù)類別與預(yù)處理方法速學(xué),有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進步,早日升職加薪2023-02-02Python ORM框架SQLAlchemy學(xué)習(xí)筆記之關(guān)系映射實例
這篇文章主要介紹了Python ORM框架SQLAlchemy學(xué)習(xí)筆記之關(guān)系映射實例,Classic (經(jīng)典模式)和Modern (現(xiàn)代模式),分別介紹了,需要的朋友可以參考下2014-06-06