解决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 base64 decode incorrect padding错误解决方法
Jan 08 Python
Python Paramiko模块的使用实际案例
Feb 01 Python
python爬虫之xpath的基本使用详解
Apr 18 Python
Python爬虫的两套解析方法和四种爬虫实现过程
Jul 20 Python
用Pytorch训练CNN(数据集MNIST,使用GPU的方法)
Aug 19 Python
python生成requirements.txt的两种方法
Sep 18 Python
Django admin 实现search_fields精确查询实例
Mar 30 Python
python入门:argparse浅析 nargs='+'作用
Jul 12 Python
Django框架安装及项目创建过程解析
Sep 14 Python
Python中免验证跳转到内容页的实例代码
Oct 23 Python
Django用户认证系统如何实现自定义
Nov 12 Python
python 利用matplotlib在3D空间中绘制平面的案例
Feb 06 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相关资料
2006/10/09 PHP
PHP XML备份Mysql数据库
2009/05/27 PHP
php jquery 实现新闻标签分类与无刷新分页
2009/12/18 PHP
PHPer 需要了解的 5 个 Composer 小技巧
2014/08/18 PHP
laravel5.6 框架操作数据 Eloquent ORM用法示例
2020/01/26 PHP
JQuery上传插件Uploadify使用详解及错误处理
2010/04/27 Javascript
jQuery的Ajax时无响应数据的解决方法
2010/05/25 Javascript
JavaScript高级程序设计 阅读笔记(二十一) JavaScript中的XML
2012/09/14 Javascript
js图片自动切换效果处理代码
2013/05/07 Javascript
javascript模拟地球旋转效果代码实例
2013/12/02 Javascript
JQuery zClip插件实现复制页面内容到剪贴板
2015/11/02 Javascript
jQuery的选择器中的通配符[id^='code']或[name^='code']及jquery选择器总结
2015/12/24 Javascript
Bootstrap Paginator分页插件使用方法详解
2016/05/30 Javascript
react-router v4如何使用history控制路由跳转详解
2018/01/09 Javascript
Vue二次封装axios为插件使用详解
2018/05/21 Javascript
js中int和string数据类型互相转化实例
2019/01/16 Javascript
通过扫小程序码实现网站登陆功能
2019/08/22 Javascript
在vue中阻止浏览器后退的实例
2019/11/06 Javascript
python实现删除文件与目录的方法
2014/11/10 Python
Python实现的简单读写csv文件操作示例
2018/07/12 Python
Python实现最大子序和的方法示例
2019/07/05 Python
pygame实现俄罗斯方块游戏(AI篇2)
2019/10/29 Python
解决pycharm debug时界面下方不出现step等按钮及变量值的问题
2020/06/09 Python
Python中bisect的用法及示例详解
2020/07/20 Python
Python selenium如何打包静态网页并下载
2020/08/12 Python
Python类成员继承重写的实现
2020/09/16 Python
Canvas获取视频第一帧缩略图的实现
2020/11/11 HTML / CSS
Expedia法国:全球最大在线旅游公司
2018/09/30 全球购物
在线购买澳大利亚设计师手拿包和奢华晚装手袋:Olga Berg
2019/03/20 全球购物
PHP如何删除一个Cookie值
2012/11/15 面试题
高中美术教师事迹材料
2014/08/22 职场文书
年会邀请函范文
2015/01/30 职场文书
教导主任个人总结
2015/03/03 职场文书
高考1977观后感
2015/06/04 职场文书
狂人日记读书笔记
2015/06/30 职场文书
Java中CyclicBarrier和CountDownLatch的用法与区别
2021/08/23 Java/Android