shaoheshaohe 发表于 2020-11-23 08:51:32

tf重复加载计算图,会导致奇葩错误

本帖最后由 shaoheshaohe 于 2020-11-23 09:09 编辑

遇到下面这个问题,发现网上很多解决办法都在误导,其实报错已经很明显说明问题的根源,只是我们不一定找到问题的根源。报错显示 不能在快照中找到 对应的键值。报错信息: tensorflow\tensorflow\core\framework\op_kernel.cc:1318] OP_REQUIRES failed at save_restore_v2_ops.cc:184 : Not found: Key Variable not found in checkpoint
Traceback (most recent call last):saver.restore(sess, kpt.model_checkpoint_path)
File "D:\Program Files\Develop\Python\Anaconda3\envs\python2\lib\site-packages\tensorflow\python\training\saver.py", line 1802, in restore
{self.saver_def.filename_tensor_name: save_path})
File "D:\Program Files\Develop\Python\Anaconda3\envs\python2\lib\site-packages\tensorflow\python\client\session.py", line 900, in run
run_metadata_ptr)
File "D:\Program Files\Develop\Python\Anaconda3\envs\python2\lib\site-packages\tensorflow\python\client\session.py", line 1135, in _run
feed_dict_tensor, options, run_metadata)
File "D:\Program Files\Develop\Python\Anaconda3\envs\python2\lib\site-packages\tensorflow\python\client\session.py", line 1316, in _do_run
run_metadata)
File "D:\Program Files\Develop\Python\Anaconda3\envs\python2\lib\site-packages\tensorflow\python\client\session.py", line 1335, in _do_call
raise type(e)(node_def, op, message)
tensorflow.python.framework.errors_impl.NotFoundError: <exception str() failed> 问题分析:报错显示 不能在快照中找到 对应的键值

但是,真正的原因是:重复加载计算图。将第二次加载计算图的代码去掉,就OK了。这是coding bug导致的错误。但若只看报错信息,无论如何也是想不到这个原因的。
页: [1]
查看完整版本: tf重复加载计算图,会导致奇葩错误