Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Restoring from checkpoint failed. This is most likely due to a Variable name or other graph key that is missing from the checkpoint. Please ensure that you have not altered the graph expected based on the checkpoint. Original error: #127

Open
a281153685 opened this issue Apr 2, 2022 · 1 comment

Comments

@a281153685
Copy link

您好,我在运行python main.py --mode=demo --demo_model=1521112368时出现模型加载错误,应该怎么解决?

.\data_path_save\1521112368\checkpoints/model-31680
INFO:tensorflow:Restoring parameters from .\data_path_save\1521112368\checkpoints/model-31680
Restoring parameters from .\data_path_save\1521112368\checkpoints/model-31680
2022-04-02 17:45:54.674463: W tensorflow/core/framework/op_kernel.cc:1753] OP_REQUIRES failed at save_restore_v2_ops.cc:184 : Not found: Key Variable not found in checkpoint
Traceback (most recent call last):
File "C:\Users\WO\anaconda3\envs\NLP_KG\lib\site-packages\tensorflow\python\client\session.py", line 1365, in _do_call
return fn(*args)
File "C:\Users\WO\anaconda3\envs\NLP_KG\lib\site-packages\tensorflow\python\client\session.py", line 1349, in _run_fn
return self._call_tf_sessionrun(options, feed_dict, fetch_list,
File "C:\Users\WO\anaconda3\envs\NLP_KG\lib\site-packages\tensorflow\python\client\session.py", line 1441, in _call_tf_sessionrun
return tf_session.TF_SessionRun_wrapper(self._session, options, feed_dict,
tensorflow.python.framework.errors_impl.NotFoundError: Key Variable not found in checkpoint
[[{{node save/RestoreV2}}]]

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:\Users\WO\anaconda3\envs\NLP_KG\lib\site-packages\tensorflow\python\training\saver.py", line 1298, in restore
sess.run(self.saver_def.restore_op_name,
File "C:\Users\WO\anaconda3\envs\NLP_KG\lib\site-packages\tensorflow\python\client\session.py", line 957, in run
result = self._run(None, fetches, feed_dict, options_ptr,
File "C:\Users\WO\anaconda3\envs\NLP_KG\lib\site-packages\tensorflow\python\client\session.py", line 1180, in _run
results = self._do_run(handle, final_targets, final_fetches,
File "C:\Users\WO\anaconda3\envs\NLP_KG\lib\site-packages\tensorflow\python\client\session.py", line 1358, in _do_run
return self._do_call(_run_fn, feeds, fetches, targets, options,
File "C:\Users\WO\anaconda3\envs\NLP_KG\lib\site-packages\tensorflow\python\client\session.py", line 1384, in _do_call
raise type(e)(node_def, op, message)
tensorflow.python.framework.errors_impl.NotFoundError: Key Variable not found in checkpoint
[[node save/RestoreV2 (defined at E:/WorkSpace/nlp_KG/zh-NER-TF-master/main.py:108) ]]

Original stack trace for 'save/RestoreV2':
File "E:\PyCharm\PyCharm Community Edition 2021.3.3\plugins\python-ce\helpers\pydev\pydevd.py", line 2173, in
main()
File "E:\PyCharm\PyCharm Community Edition 2021.3.3\plugins\python-ce\helpers\pydev\pydevd.py", line 2164, in main
globals = debugger.run(setup['file'], None, None, is_module)
File "E:\PyCharm\PyCharm Community Edition 2021.3.3\plugins\python-ce\helpers\pydev\pydevd.py", line 1476, in run
return self._exec(is_module, entry_point_fn, module_name, file, globals, locals)
File "E:\PyCharm\PyCharm Community Edition 2021.3.3\plugins\python-ce\helpers\pydev\pydevd.py", line 1483, in _exec
pydev_imports.execfile(file, globals, locals) # execute the script
File "E:\PyCharm\PyCharm Community Edition 2021.3.3\plugins\python-ce\helpers\pydev_pydev_imps_pydev_execfile.py", line 18, in execfile
exec(compile(contents+"\n", file, 'exec'), glob, loc)
File "E:/WorkSpace/nlp_KG/zh-NER-TF-master/main.py", line 108, in
saver = tf.compat.v1.train.Saver()
File "C:\Users\WO\anaconda3\envs\NLP_KG\lib\site-packages\tensorflow\python\training\saver.py", line 836, in init
self.build()
File "C:\Users\WO\anaconda3\envs\NLP_KG\lib\site-packages\tensorflow\python\training\saver.py", line 848, in build
self._build(self._filename, build_save=True, build_restore=True)
File "C:\Users\WO\anaconda3\envs\NLP_KG\lib\site-packages\tensorflow\python\training\saver.py", line 876, in _build
self.saver_def = self._builder._build_internal( # pylint: disable=protected-access
File "C:\Users\WO\anaconda3\envs\NLP_KG\lib\site-packages\tensorflow\python\training\saver.py", line 515, in _build_internal
restore_op = self._AddRestoreOps(filename_tensor, saveables,
File "C:\Users\WO\anaconda3\envs\NLP_KG\lib\site-packages\tensorflow\python\training\saver.py", line 335, in _AddRestoreOps
all_tensors = self.bulk_restore(filename_tensor, saveables, preferred_shard,
File "C:\Users\WO\anaconda3\envs\NLP_KG\lib\site-packages\tensorflow\python\training\saver.py", line 583, in bulk_restore
return io_ops.restore_v2(filename_tensor, names, slices, dtypes)
File "C:\Users\WO\anaconda3\envs\NLP_KG\lib\site-packages\tensorflow\python\ops\gen_io_ops.py", line 1503, in restore_v2
_, _, _op, _outputs = _op_def_library._apply_op_helper(
File "C:\Users\WO\anaconda3\envs\NLP_KG\lib\site-packages\tensorflow\python\framework\op_def_library.py", line 742, in _apply_op_helper
op = g._create_op_internal(op_type_name, inputs, dtypes=None,
File "C:\Users\WO\anaconda3\envs\NLP_KG\lib\site-packages\tensorflow\python\framework\ops.py", line 3319, in _create_op_internal
ret = Operation(
File "C:\Users\WO\anaconda3\envs\NLP_KG\lib\site-packages\tensorflow\python\framework\ops.py", line 1791, in init
self._traceback = tf_stack.extract_stack()

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:\Users\WO\anaconda3\envs\NLP_KG\lib\site-packages\tensorflow\python\training\py_checkpoint_reader.py", line 69, in get_tensor
return CheckpointReader.CheckpointReader_GetTensor(
RuntimeError: Key _CHECKPOINTABLE_OBJECT_GRAPH not found in checkpoint

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:\Users\WO\anaconda3\envs\NLP_KG\lib\site-packages\tensorflow\python\training\saver.py", line 1309, in restore
names_to_keys = object_graph_key_mapping(save_path)
File "C:\Users\WO\anaconda3\envs\NLP_KG\lib\site-packages\tensorflow\python\training\saver.py", line 1627, in object_graph_key_mapping
object_graph_string = reader.get_tensor(trackable.OBJECT_GRAPH_PROTO_KEY)
File "C:\Users\WO\anaconda3\envs\NLP_KG\lib\site-packages\tensorflow\python\training\py_checkpoint_reader.py", line 74, in get_tensor
error_translator(e)
File "C:\Users\WO\anaconda3\envs\NLP_KG\lib\site-packages\tensorflow\python\training\py_checkpoint_reader.py", line 35, in error_translator
raise errors_impl.NotFoundError(None, None, error_message)
tensorflow.python.framework.errors_impl.NotFoundError: Key _CHECKPOINTABLE_OBJECT_GRAPH not found in checkpoint

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:\Users\WO\anaconda3\envs\NLP_KG\lib\contextlib.py", line 131, in exit
self.gen.throw(type, value, traceback)
File "C:\Users\WO\anaconda3\envs\NLP_KG\lib\site-packages\tensorflow\python\framework\ops.py", line 5399, in get_controller
yield g
File "E:/WorkSpace/nlp_KG/zh-NER-TF-master/main.py", line 116, in
saver.restore(sess, ckpt_file)
File "C:\Users\WO\anaconda3\envs\NLP_KG\lib\site-packages\tensorflow\python\training\saver.py", line 1314, in restore
raise _wrap_restore_error_with_msg(
tensorflow.python.framework.errors_impl.NotFoundError: Restoring from checkpoint failed. This is most likely due to a Variable name or other graph key that is missing from the checkpoint. Please ensure that you have not altered the graph expected based on the checkpoint. Original error:

Key Variable not found in checkpoint
[[node save/RestoreV2 (defined at E:/WorkSpace/nlp_KG/zh-NER-TF-master/main.py:108) ]]

Original stack trace for 'save/RestoreV2':
File "E:\PyCharm\PyCharm Community Edition 2021.3.3\plugins\python-ce\helpers\pydev\pydevd.py", line 2173, in
main()
File "E:\PyCharm\PyCharm Community Edition 2021.3.3\plugins\python-ce\helpers\pydev\pydevd.py", line 2164, in main
globals = debugger.run(setup['file'], None, None, is_module)
File "E:\PyCharm\PyCharm Community Edition 2021.3.3\plugins\python-ce\helpers\pydev\pydevd.py", line 1476, in run
return self._exec(is_module, entry_point_fn, module_name, file, globals, locals)
File "E:\PyCharm\PyCharm Community Edition 2021.3.3\plugins\python-ce\helpers\pydev\pydevd.py", line 1483, in _exec
pydev_imports.execfile(file, globals, locals) # execute the script
File "E:\PyCharm\PyCharm Community Edition 2021.3.3\plugins\python-ce\helpers\pydev_pydev_imps_pydev_execfile.py", line 18, in execfile
exec(compile(contents+"\n", file, 'exec'), glob, loc)
File "E:/WorkSpace/nlp_KG/zh-NER-TF-master/main.py", line 108, in
saver = tf.compat.v1.train.Saver()
File "C:\Users\WO\anaconda3\envs\NLP_KG\lib\site-packages\tensorflow\python\training\saver.py", line 836, in init
self.build()
File "C:\Users\WO\anaconda3\envs\NLP_KG\lib\site-packages\tensorflow\python\training\saver.py", line 848, in build
self._build(self._filename, build_save=True, build_restore=True)
File "C:\Users\WO\anaconda3\envs\NLP_KG\lib\site-packages\tensorflow\python\training\saver.py", line 876, in _build
self.saver_def = self._builder._build_internal( # pylint: disable=protected-access
File "C:\Users\WO\anaconda3\envs\NLP_KG\lib\site-packages\tensorflow\python\training\saver.py", line 515, in _build_internal
restore_op = self._AddRestoreOps(filename_tensor, saveables,
File "C:\Users\WO\anaconda3\envs\NLP_KG\lib\site-packages\tensorflow\python\training\saver.py", line 335, in _AddRestoreOps
all_tensors = self.bulk_restore(filename_tensor, saveables, preferred_shard,
File "C:\Users\WO\anaconda3\envs\NLP_KG\lib\site-packages\tensorflow\python\training\saver.py", line 583, in bulk_restore
return io_ops.restore_v2(filename_tensor, names, slices, dtypes)
File "C:\Users\WO\anaconda3\envs\NLP_KG\lib\site-packages\tensorflow\python\ops\gen_io_ops.py", line 1503, in restore_v2
_, _, _op, _outputs = _op_def_library._apply_op_helper(
File "C:\Users\WO\anaconda3\envs\NLP_KG\lib\site-packages\tensorflow\python\framework\op_def_library.py", line 742, in _apply_op_helper
op = g._create_op_internal(op_type_name, inputs, dtypes=None,
File "C:\Users\WO\anaconda3\envs\NLP_KG\lib\site-packages\tensorflow\python\framework\ops.py", line 3319, in _create_op_internal
ret = Operation(
File "C:\Users\WO\anaconda3\envs\NLP_KG\lib\site-packages\tensorflow\python\framework\ops.py", line 1791, in init
self._traceback = tf_stack.extract_stack()

@lala-haha74
Copy link

你好,请问解决了吗,我也遇到了相同的问题

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants