解决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 回调函数和回调方法的实现分析
Mar 23 Python
使用python实现生成用户信息
Mar 20 Python
python笔记:mysql、redis操作方法
Jun 28 Python
Python正则表达式知识汇总
Sep 22 Python
Centos部署django服务nginx+uwsgi的方法
Jan 02 Python
Python中numpy模块常见用法demo实例小结
Mar 16 Python
Python对接六大主流数据库(只需三步)
Jul 31 Python
Python 中的 global 标识对变量作用域的影响
Aug 12 Python
Python处理mysql特殊字符的问题
Mar 02 Python
Python自动化操作实现图例绘制
Jul 09 Python
python统计mysql数据量变化并调用接口告警的示例代码
Sep 21 Python
Python 找出英文单词列表(list)中最长单词链
Dec 14 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
模拟SQLSERVER的两个函数:dateadd(),datediff()
2006/10/09 PHP
Mysql和网页显示乱码解决方法集锦
2008/03/27 PHP
php计算两个日期时间差(返回年、月、日)
2014/06/19 PHP
Thinkphp5 微信公众号token验证不成功的原因及解决方法
2017/11/12 PHP
Javascript绝句欣赏 一些经典的js代码
2012/02/22 Javascript
关于javascript原型的修改与重写(覆盖)差别详解
2016/08/31 Javascript
20行js代码实现的贪吃蛇小游戏
2017/06/20 Javascript
EasyUI Tree树组件无限循环的解决方法
2017/09/27 Javascript
详解Vue Elememt-UI构建管理后台
2018/02/27 Javascript
vue实现简单loading进度条
2018/06/06 Javascript
详解如何用typescript开发koa2的二三事
2018/11/13 Javascript
深入浅析Vue中mixin和extend的区别和使用场景
2019/08/01 Javascript
JavaScript在web自动化测试中的作用示例详解
2019/08/25 Javascript
详解vuex数据传输的两种方式及this.$store undefined的解决办法
2019/08/26 Javascript
js刷新页面location.reload()用法详解
2019/12/09 Javascript
jQuery--遍历操作实例小结【后代、同胞及过滤】
2020/05/22 jQuery
关于javascript中的promise的用法和注意事项(推荐)
2021/01/15 Javascript
[03:14]2014DOTA2西雅图国际邀请赛 EG战队巡礼
2014/07/07 DOTA
python中的对象拷贝示例 python引用传递
2014/01/23 Python
利用Python实现Windows定时关机功能
2017/03/21 Python
python3 读取Excel表格中的数据
2018/10/16 Python
检测tensorflow是否使用gpu进行计算的方式
2020/02/03 Python
Python类继承和多态原理解析
2020/02/05 Python
Python类的绑定方法和非绑定方法实例解析
2020/03/04 Python
Python批量安装卸载1000个apk的方法
2020/04/10 Python
python3列表删除大量重复元素remove()方法的问题详解
2021/01/04 Python
详解css3自定义滚动条样式写法
2017/12/25 HTML / CSS
美国知名的百货清仓店:Neiman Marcus Last Call
2016/08/03 全球购物
芬兰设计商店美国:Finnish Design Shop US
2019/03/25 全球购物
社区七一党员活动方案
2014/01/25 职场文书
《忆江南》教学反思
2014/04/07 职场文书
员工保密承诺书
2014/05/28 职场文书
科学发展观活动总结
2014/08/28 职场文书
2014年超市工作总结
2014/11/19 职场文书
创业计划书之闲置物品置换中心
2019/12/25 职场文书
 Redis 串行生成顺序编码的方法实现
2022/04/03 Redis