解决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 相关文章推荐
深入理解NumPy简明教程---数组3(组合)
Dec 17 Python
python安装模块如何通过setup.py安装(超简单)
May 05 Python
Python3中的列表生成式、生成器与迭代器实例详解
Jun 11 Python
python多线程与多进程及其区别详解
Aug 08 Python
pytorch torch.nn.AdaptiveAvgPool2d()自适应平均池化函数详解
Jan 03 Python
python3实现网页版raspberry pi(树莓派)小车控制
Feb 12 Python
pytorch:model.train和model.eval用法及区别详解
Feb 20 Python
Python reduce函数作用及实例解析
May 08 Python
Win10环境中如何实现python2和python3并存
Jul 20 Python
无惧面试,带你搞懂python 装饰器
Aug 17 Python
Python爬虫之爬取哔哩哔哩热门视频排行榜
Apr 28 Python
基于PyTorch实现一个简单的CNN图像分类器
May 29 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
基于OpenCV的PHP图像人脸识别技术
2009/10/11 PHP
计算php页面运行时间的函数介绍
2013/07/01 PHP
PHP记录搜索引擎蜘蛛访问网站足迹的方法
2015/04/15 PHP
wamp服务器访问php非常缓慢的解决过程
2015/07/01 PHP
PHP中字符串长度的截取用法示例
2017/01/12 PHP
PHP中创建和编辑Excel表格的方法
2018/09/13 PHP
PHP的Trait机制原理与用法分析
2019/10/18 PHP
Mozilla中显示textarea中选择的文字
2006/09/07 Javascript
有一段有意思的代码-javascript现实多行信息
2007/08/26 Javascript
JS继承--原型链继承和类式继承
2013/04/08 Javascript
JQuery加载图片自适应固定大小的DIV
2013/09/12 Javascript
javascript 实现 原路返回
2015/01/21 Javascript
js点击选择文本的方法
2015/02/09 Javascript
深入浅析JavaScript中的scrollTop
2016/07/11 Javascript
Bootstrap模态框(Modal)实现过渡效果
2017/03/17 Javascript
深入浅析Vue全局组件与局部组件的区别
2018/06/15 Javascript
jQuery实现表格隔行换色
2018/09/01 jQuery
JS实现可针对算术表达式求值的计算器功能示例
2018/09/04 Javascript
jQuery实现鼠标滑动切换图片
2020/05/27 jQuery
JavaScript Window浏览器对象模型原理解析
2020/05/30 Javascript
[02:49:21]2019完美盛典全程录像
2019/12/08 DOTA
python写的一个squid访问日志分析的小程序
2014/09/17 Python
Python简单实现自动删除目录下空文件夹的方法
2017/08/29 Python
pandas.DataFrame.to_json按行转json的方法
2018/06/05 Python
Python3实现将本地JSON大数据文件写入MySQL数据库的方法
2018/06/13 Python
python 中字典嵌套列表的方法
2018/07/03 Python
python3 cvs将数据读取为字典的方法
2018/12/22 Python
python输出电脑上所有的串口名的方法
2019/07/02 Python
Python代码块及缓存机制原理详解
2019/12/13 Python
更新升级python和pip版本后不生效的问题解决
2020/04/17 Python
html5默认气泡修改的代码详解
2020/03/13 HTML / CSS
森海塞尔美国官网:Sennheiser耳机与耳麦
2017/07/19 全球购物
e路東瀛(JAPANiCAN)香港:日本旅游、日本酒店和温泉旅馆预订
2018/11/21 全球购物
工程管理造价应届生求职信
2013/11/13 职场文书
秋天的怀念教学反思
2014/04/28 职场文书
解决pytorch 损失函数中输入输出不匹配的问题
2021/06/05 Python