tensorflow加载saver.restore目录报错

   本人python小白,将自己遇到的难点bug记录下来,希望对后人有用。

   最近遇到报错如下:  

        InvalidArgumentError (see above for traceback): Unsuccessful TensorSliceReader constructor: Failed to get matching files on .///home/wujing/pythondemo/test/save_net.ckpt: Not found: .///home/wujing/pythondemo/test
	 [[Node: save/RestoreV2_7 = RestoreV2[dtypes=[DT_FLOAT], _device="/job:localhost/replica:0/task:0/cpu:0"](_arg_save/Const_0_0, save/RestoreV2_7/tensor_names, save/RestoreV2_7/shape_and_slices)]]
   期间搜索各种无果,最后在这篇http://blog.csdn.net/u014283248/article/details/64440019找到解决办法,特此记录:

  修改之前代码:

saver.restore(sess, '/home/test/model.ckpt')
修改之后:
module_file =  tf.train.latest_checkpoint('/home/test/model.ckpt')
with tf.Session() as sess:
   sess.run(tf.global_variables_initializer())
   if module_file is not None:
      saver.restore(sess, module_file)
然后这个bug就解决啦!
但是下面其他地方出现了一个新的bug,没办法,继续解决,程序员的宿命。
 
  
 
 

你可能感兴趣的:(机器学习)