解决tensorflow1.x版本加载saver.restore目录报错的问题


Posted in Python onJuly 26, 2018

这个错误是最新的错误哈,目前只在tensorflow上的github仓库上面有提出,所以你在百度上面找不到。

是个tensorflow的bug十天前提出的,只有github仓库上一个地方有提出。

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')

如果你目录太复杂实在搞不明白用这个(默认加载checkout 文件中的最新的保存的数据):

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目录报错的问题就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持三水点靠木。

Python 相关文章推荐
Python实现模拟时钟代码推荐
Nov 08 Python
老生常谈进程线程协程那些事儿
Jul 24 Python
flask框架实现连接sqlite3数据库的方法分析
Jul 16 Python
Python使用pickle模块储存对象操作示例
Aug 15 Python
Python合并同一个文件夹下所有PDF文件的方法
Mar 11 Python
Django中URL的参数传递的实现
Aug 04 Python
django项目登录中使用图片验证码的实现方法
Aug 15 Python
python生成requirements.txt的两种方法
Sep 18 Python
Python浮点数四舍五入问题的分析与解决方法
Nov 19 Python
python 使用递归回溯完美解决八皇后的问题
Feb 26 Python
解决Jupyter NoteBook输出的图表太小看不清问题
Apr 16 Python
python闭包与引用以及需要注意的陷阱
Sep 18 Python
Flask web开发处理POST请求实现(登录案例)
Jul 26 #Python
基于tensorflow加载部分层的方法
Jul 26 #Python
利用python画出折线图
Jul 26 #Python
浅谈flask源码之请求过程
Jul 26 #Python
python画折线图的程序
Jul 26 #Python
TensorFlow利用saver保存和提取参数的实例
Jul 26 #Python
78行Python代码实现现微信撤回消息功能
Jul 26 #Python
You might like
浅谈PHP语法(1)
2006/10/09 PHP
PHP的FTP学习(二)
2006/10/09 PHP
ThinkPHP模板之变量输出、自定义函数与判断语句用法
2014/11/01 PHP
PHP中一些可以替代正则表达式函数的字符串操作函数
2014/11/17 PHP
PHP使用Curl实现模拟登录及抓取数据功能示例
2018/04/27 PHP
基于php伪静态的实现方法解析
2020/07/31 PHP
DWR Ext 加载数据
2009/03/22 Javascript
网页开发中的容易忽略的问题 javascript HTML中的table
2009/04/15 Javascript
判断控件是否已加载完成的代码
2010/02/24 Javascript
表单类各种类型(文本框)失去焦点效果jquery代码
2013/04/26 Javascript
jQuery 回车事件enter使用示例
2014/02/18 Javascript
javascript根据时间生成m位随机数最大13位
2014/10/30 Javascript
还不懂递归?读完这篇文章保证你会懂
2018/07/29 Javascript
对vue中v-if的常见使用方法详解
2018/09/28 Javascript
基于layPage插件实现两种分页方式浅析
2019/07/27 Javascript
JavaScript中判断为整数的多种方式及保留两位小数的方法
2019/09/09 Javascript
解决layui调用自定义方法提示未定义的问题
2019/09/14 Javascript
vue excel上传预览和table内容下载到excel文件中
2019/12/10 Javascript
Vue简单封装axios之解决post请求后端接收不到参数问题
2020/02/16 Javascript
详解Typescript 内置的模块导入兼容方式
2020/05/31 Javascript
Vue开发中常见的套路和技巧总结
2020/11/24 Vue.js
Python中的测试模块unittest和doctest的使用教程
2015/04/14 Python
使用python爬虫获取黄金价格的核心代码
2018/06/13 Python
centos6.5安装python3.7.1之后无法使用pip的解决方案
2019/02/14 Python
Python3.5文件读与写操作经典实例详解
2019/05/01 Python
python django生成迁移文件的实例
2019/08/31 Python
python根据时间获取周数代码实例
2019/09/30 Python
python为Django项目上的每个应用程序创建不同的自定义404页面(最佳答案)
2020/03/09 Python
Django 拼接两个queryset 或是两个不可以相加的对象实例
2020/03/28 Python
html5中canvas学习笔记1-画板的尺寸与实际显示尺寸
2013/01/06 HTML / CSS
四年的大学生生活自我评价
2013/12/09 职场文书
清华大学自主招生自荐信
2014/01/29 职场文书
党的群众路线教育实践活动对照检查材料思想汇报(党员篇)
2014/09/25 职场文书
于丹讲座视频观后感
2015/06/15 职场文书
小学生暑假生活总结
2015/07/13 职场文书
css常用字体属性与背景属性介绍
2022/02/28 HTML / CSS