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 'deepspeech/logits:0' refers to a Tensor which does not exist. The operation, 'deepspeech/logits', does not exist in the graph." #121

Closed
Hybrogen opened this issue Jun 19, 2023 · 1 comment

Comments

@Hybrogen
Copy link

error:

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Traceback (most recent call last):
  File "D:\HWork\NEW08\AD-NeRF\data_util\deepspeech_features\extract_ds_features.py", line 128, in <module>
    main()
  File "D:\HWork\NEW08\AD-NeRF\data_util\deepspeech_features\extract_ds_features.py", line 120, in main
    extract_features(
  File "D:\HWork\NEW08\AD-NeRF\data_util\deepspeech_features\extract_ds_features.py", line 80, in extract_features
    conv_audios_to_deepspeech(
  File "D:\HWork\NEW08\AD-NeRF\data_util\deepspeech_features\deepspeech_features.py", line 41, in conv_audios_to_deepspeech
    graph, logits_ph, input_node_ph, input_lengths_ph = prepare_deepspeech_net(
  File "D:\HWork\NEW08\AD-NeRF\data_util\deepspeech_features\deepspeech_features.py", line 106, in prepare_deepspeech_net
    logits_ph = graph.get_tensor_by_name("deepspeech/logits:0")
  File "D:\HPrograms\H_OnInstall\Python\Python310\lib\site-packages\tensorflow\python\framework\ops.py", line 4188, in get_tensor_by_name
    return self.as_graph_element(name, allow_tensor=True, allow_operation=False)
  File "D:\HPrograms\H_OnInstall\Python\Python310\lib\site-packages\tensorflow\python\framework\ops.py", line 4012, in as_graph_element
    return self._as_graph_element_locked(obj, allow_tensor, allow_operation)
  File "D:\HPrograms\H_OnInstall\Python\Python310\lib\site-packages\tensorflow\python\framework\ops.py", line 4052, in _as_graph_element_locked
    raise KeyError("The name %s refers to a Tensor which does not "
KeyError: "The name 'deepspeech/logits:0' refers to a Tensor which does not exist. The operation, 'deepspeech/logits', does not exist in the graph."

i find this error in ops.py and find out this:

# line 4049
if op_name in self._nodes_by_name:
  op = self._nodes_by_name[op_name]
else:
  raise KeyError("The name %s refers to a Tensor which does not "
                 "exist. The operation, %s, does not exist in the "
                 "graph." % (repr(name), repr(op_name)))

so i try to print [tensor.name for tensor in graph._nodes_by_name] before logits_ph = graph.get_tensor_by_name("deepspeech/logits:0") in deepspeech_features.py.
but it is empty. i wonder why and how to fix it~

@Hybrogen
Copy link
Author

find out reason is that the version of tensorflow which origin project used is 1.15.2, but new version has some different.
anyway this change will be solve:

# data_util/deepspeech_features/deepspeech_features.py
def prepare_deepspeech_net(deepspeech_pb_path):
    # Load graph and place_holders:
    with tf.io.gfile.GFile(deepspeech_pb_path, "rb") as f:
        graph_def = tf.compat.v1.GraphDef()
        graph_def.ParseFromString(f.read())

    graph = tf.compat.v1.get_default_graph()

    tf.import_graph_def(graph_def, name="deepspeech")
    # check all graphs
    # print('~'*50, [tensor for tensor in graph._nodes_by_name], '~'*50)
    # print('~'*50, [tensor.name for tensor in graph.get_operations()], '~'*50)
    # i modified
    logits_ph = graph.get_tensor_by_name("logits:0")
    input_node_ph = graph.get_tensor_by_name("input_node:0")
    input_lengths_ph = graph.get_tensor_by_name("input_lengths:0")
    # original
    # logits_ph = graph.get_tensor_by_name("deepspeech/logits:0")
    # input_node_ph = graph.get_tensor_by_name("deepspeech/input_node:0")
    # input_lengths_ph = graph.get_tensor_by_name("deepspeech/input_lengths:0")

    return graph, logits_ph, input_node_ph, input_lengths_ph

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

1 participant