解决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代码制作configure文件示例
Jul 28 Python
Python中给List添加元素的4种方法分享
Nov 28 Python
Python的Django框架中的URL配置与松耦合
Jul 15 Python
python3使用scrapy生成csv文件代码示例
Dec 28 Python
python框架中flask知识点总结
Aug 17 Python
Python 运行 shell 获取输出结果的实例
Jan 07 Python
使用OpenCV实现仿射变换—旋转功能
Aug 29 Python
在Python中等距取出一个数组其中n个数的实现方式
Nov 27 Python
pytorch dataloader 取batch_size时候出现bug的解决方式
Feb 20 Python
解决pymysql cursor.fetchall() 获取不到数据的问题
May 15 Python
浅谈opencv自动光学检测、目标分割和检测(连通区域和findContours)
Jun 04 Python
python 如何快速复制序列
Sep 07 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操作数组相关函数
2011/02/03 PHP
jquery获取焦点和失去焦点事件代码
2013/04/21 Javascript
js判断两个日期是否相等的方法
2013/09/10 Javascript
使用js实现一个可编辑的select下拉列表
2014/02/20 Javascript
简单的jquery左侧导航栏和页面选中效果
2014/08/21 Javascript
jQuery模拟黑客帝国矩阵效果实例
2015/06/28 Javascript
JS特效实现图片自动播放并可控的效果
2015/07/31 Javascript
D3.js实现雷达图的方法详解
2016/09/22 Javascript
jQuery操作复选框(CheckBox)的取值赋值实现代码
2017/01/10 Javascript
JS 使用 window对象的print方法实现分页打印功能
2018/05/16 Javascript
用Vue编写抽象组件的方法
2019/05/06 Javascript
vue 地图可视化 maptalks 篇实例代码详解
2019/05/21 Javascript
sortable+element 实现表格行拖拽的方法示例
2019/06/07 Javascript
vue实现吸顶、锚点和滚动高亮按钮效果
2019/10/21 Javascript
微信小程序实现限制用户转发功能的实例代码
2020/02/22 Javascript
JS实现公告上线滚动效果
2021/01/10 Javascript
[01:02:18]VGJ.S vs infamous Supermajor 败者组 BO3 第一场 6.4
2018/06/05 DOTA
[59:48]LGD vs IG 2018国际邀请赛小组赛BO2 第一场 8.18
2018/08/19 DOTA
Mac OS X10.9安装的Python2.7升级Python3.3步骤详解
2013/12/04 Python
Python警察与小偷的实现之一客户端与服务端通信实例
2014/10/09 Python
python中numpy基础学习及进行数组和矢量计算
2017/02/12 Python
Python编程之变量赋值操作实例分析
2017/07/24 Python
Python数据结构之双向链表的定义与使用方法示例
2018/01/16 Python
python利用百度云接口实现车牌识别的示例
2020/02/21 Python
Numpy一维线性插值函数的用法
2020/04/22 Python
利用python实现汉诺塔游戏
2021/03/01 Python
20佳惊艳的HTML5应用程序示例分享
2011/05/03 HTML / CSS
英国的一家创新礼品和小工具零售商:Menkind
2019/08/24 全球购物
介绍一下OSI七层模型
2012/07/03 面试题
健康家庭事迹材料
2014/05/02 职场文书
办公室主任岗位承诺书
2014/05/29 职场文书
公司年底活动方案
2014/08/17 职场文书
自愿离婚协议书范文2014
2014/10/12 职场文书
2014年个人工作总结范文
2014/11/07 职场文书
pytorch查看网络参数显存占用量等操作
2021/05/12 Python
详解Python中下划线的5种含义
2021/07/15 Python