wide and deep example error: KeyError: "The name 'head/truediv:0' refers to a Tensor which does not exist. The operation, 'head/truediv', does not exist in the graph."
with same error from: https://stackoverflow.com/questions/49579096/tensorflow-wide-and-deep-example-error I make some code removing and it works:
--- a/official/wide_deep/wide_deep.py
+++ b/official/wide_deep/wide_deep.py
@@ -195,14 +195,9 @@ def main(argv):
return input_fn(test_file, 1, False, flags.batch_size)
loss_prefix = LOSS_PREFIX.get(flags.model_type, '')
- train_hooks = hooks_helper.get_train_hooks(
- flags.hooks, batch_size=flags.batch_size,
- tensors_to_log={'average_loss': loss_prefix + 'head/truediv',
- 'loss': loss_prefix + 'head/weighted_loss/Sum'})
-
# Train and evaluate the model every `flags.epochs_between_evals` epochs.
for n in range(flags.train_epochs // flags.epochs_between_evals):
- model.train(input_fn=train_input_fn, hooks=train_hooks)
+ model.train(input_fn=train_input_fn)
results = model.evaluate(input_fn=eval_input_fn)
# Display evaluation metrics
@k-w-w Could you help on this issue?
Thanks for submitting this issue. It appears that the graph produced by canned estimators changes depending on the version of tensorflow. In that case, we should remove the logging tensor hook from the wide deep model to lower maintenance cost.
Submitting a PR shortly.
@ispirmustafa - The linked PR seems like a non-ideal solution. What's the recommended way of logging tensors of interest from CannedEstimators?
best way is using tf.train.LoggingTensorHook. You need to provide the name of the tensor.
@CanoeFZH The master version of the repo works with the tensorflow nightly build. If you are running an older version of tensorflow, I would recommend checking out the r1.5 branch or one of the releases: https://github.com/tensorflow/models/releases
I have the same problem in wide and deep tutorial
in ops.py line 3365, in _as_graph_element_locked "graph." % (repr(name), repr(op_name)))
KeyError: "The name 'head/truediv:0' refers to a Tensor which does not exist. The operation, 'head/truediv', does not exist in the graph."
What I am doing wrong?
@xmutizabal what version of tensorflow are you using? As recommended above, please check out the r1.5 branch or one of the releases: https://github.com/tensorflow/models/releases.
The error comes from logging a tensor is in the graph created by the latest Tensorflow library. You can either remove the hook (see the suggestion in the original post), or use the correct release of the official models/Tensorflow.
👍
What should I do if tensorflow keep upgrading its version quickly while our system can not update the version quickly?
@CanoeFZH We create releases that can run at specific tensorflow versions. Unfortunately this does mean that you will get older versions of the code. The models in the master branch are mostly backwards compatible but we don't guarantee it.
I too getting the same error and checked the tensorflow version with the command
python3 -c 'import tensorflow as tf; print(tf.version)'
says 1.8.0 and i tried with python then
python -c 'import tensorflow as tf; print(tf.version)'
it says 1.9.0 what does that mean i didn't get it.do tensorflow changes by python versions?????
KeyError: "The name 'loss:0' refers to a Tensor which does not exist. The operation, 'loss', does not exist in the graph."
Hey guys, i'm facing an issue while using the tensorflow model. The code is running fine when it compiled in terminal but i try to make it an python API it shows the above error
output_layer = 'loss:0'
input_node = 'Placeholder:0'
# Crop the center for the specified network_input_Size
augmented_image = crop_center(augmented_image, network_input_size, network_input_size)
with tf.Session() as sess:
prob_tensor = sess.graph.get_tensor_by_name(output_layer)
predictions = sess.run(prob_tensor, {input_node: [augmented_image] })
The above code is saying an error at
prob_tensor = sess.graph.get_tensor_by_name(output_layer)