Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

KeyError: "The name 'xxxxxxxx' refers to an Operation not in the graph." #47

Closed
Mr-Nineteen opened this issue Apr 13, 2021 · 3 comments
Closed

Comments

@Mr-Nineteen
Copy link
Contributor

Environment description:

  1. python version : 3
  2. TF related installation library:
tensorflow                     2.4.1
tensorflow-datasets            4.2.0
tensorflow-estimator           2.4.0
tensorflow-metadata            0.29.0
tensorflow-recommenders-addons 0.1.0
  1. Test model address: https://github.com/Mr-Nineteen/models/blob/main/1617949817.zip
  2. test code:
import tensorflow as tf
import tensorflow_recommenders_addons as tfra

m = tf.saved_model.load("1617949817")
  1. Error message:
Traceback (most recent call last):
  File "/Users/dxwang/repo/pycharm-repo/tensorflow-2.0-demo/com/opensource/demo/tftrt/demo.py", line 4, in <module>
    m = tf.saved_model.load("1617949817")
  File "/Users/dxwang/opt/anaconda3/envs/tfra/lib/python3.6/site-packages/tensorflow/python/saved_model/load.py", line 859, in load
    return load_internal(export_dir, tags, options)["root"]
  File "/Users/dxwang/opt/anaconda3/envs/tfra/lib/python3.6/site-packages/tensorflow/python/saved_model/load.py", line 909, in load_internal
    root = load_v1_in_v2.load(export_dir, tags)
  File "/Users/dxwang/opt/anaconda3/envs/tfra/lib/python3.6/site-packages/tensorflow/python/saved_model/load_v1_in_v2.py", line 279, in load
    return loader.load(tags=tags)
  File "/Users/dxwang/opt/anaconda3/envs/tfra/lib/python3.6/site-packages/tensorflow/python/saved_model/load_v1_in_v2.py", line 225, in load
    signature=[])
  File "/Users/dxwang/opt/anaconda3/envs/tfra/lib/python3.6/site-packages/tensorflow/python/eager/wrap_function.py", line 628, in wrap_function
    collections={}),
  File "/Users/dxwang/opt/anaconda3/envs/tfra/lib/python3.6/site-packages/tensorflow/python/framework/func_graph.py", line 990, in func_graph_from_py_func
    func_outputs = python_func(*func_args, **func_kwargs)
  File "/Users/dxwang/opt/anaconda3/envs/tfra/lib/python3.6/site-packages/tensorflow/python/eager/wrap_function.py", line 87, in __call__
    return self.call_with_variable_creator_scope(self._fn)(*args, **kwargs)
  File "/Users/dxwang/opt/anaconda3/envs/tfra/lib/python3.6/site-packages/tensorflow/python/eager/wrap_function.py", line 93, in wrapped
    return fn(*args, **kwargs)
  File "/Users/dxwang/opt/anaconda3/envs/tfra/lib/python3.6/site-packages/tensorflow/python/saved_model/load_v1_in_v2.py", line 93, in load_graph
    meta_graph_def)
  File "/Users/dxwang/opt/anaconda3/envs/tfra/lib/python3.6/site-packages/tensorflow/python/training/saver.py", line 1485, in _import_meta_graph_with_return_elements
    **kwargs))
  File "/Users/dxwang/opt/anaconda3/envs/tfra/lib/python3.6/site-packages/tensorflow/python/framework/meta_graph.py", line 886, in import_scoped_meta_graph_with_return_elements
    ops.prepend_name_scope(value, scope_to_prepend_to_names))
  File "/Users/dxwang/opt/anaconda3/envs/tfra/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 3726, in as_graph_element
    return self._as_graph_element_locked(obj, allow_tensor, allow_operation)
  File "/Users/dxwang/opt/anaconda3/envs/tfra/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 3786, in _as_graph_element_locked
    "graph." % repr(name))
KeyError: "The name 'deep_dynamic_embeddings' refers to an Operation not in the graph."
@ningpingwang
Copy link

got same error on tfra 0.2.0

@Lifann
Copy link
Member

Lifann commented Jul 30, 2021

I got the same error when export graph meta to file and try to import the meta. And seems the trace to variables stops at a collection_def value to the variable. Since the de.Variable class do not hold any tensor, so the meta graph tells tensorflow that you should restore a tensor name as "deep_dynamic_embeddings" but actually it does not exist.

Currently, I'm trying to find a method to avoid dumping de.Variable in meta graph file.

@Lifann
Copy link
Member

Lifann commented Oct 15, 2021

Would you please switch to tensorflow-recommenders-addons>=0.3.0? I think it may help. The issue is caused by graph keys, which were introduced to the saved model. The new version removed the legacy keys by default.

@Lifann Lifann reopened this Oct 15, 2021
@Lifann Lifann closed this as completed Oct 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants