Any ideas on what might be causing this TensorFlow error? (Object was never used)

Question:

I am training a sequence-to-sequence model on Keras with a Tensorflow backend, mostly following the tutorial here.

  • I’m using TensorFlow v1.2.1 on a IBM Power8 machine with a P100 GPU

When it hits my model.fit_generator() line, TensorFlow throws the following error:

Object was never used (type <class 'tensorflow.python.ops.tensor_array_ops.TensorArray'>):
<tensorflow.python.ops.tensor_array_ops.TensorArray object at 0x3bfffc096dd8>
If you want to mark it as used call its "mark_used()" method.

I tried looking for unused operations/tensors, but couldn’t find any. Then, I marked every operation/tensor as used, but I still cannot get rid of this error.

Asked By: Gavin

||

Answers:

Usually this error fires up when some stateful operation in tensorflow is never passed to session.run or used as a control dependency, which means some updates will get silently dropped leading to wrong behavior. That said, try upgrading to see if the fault is some internal library and not your code.

Answered By: Alexandre Passos

I encountered this error, while working with TensorArrays, and as per the official documentation of TensorArrays: https://www.tensorflow.org/api_docs/python/tf/TensorArray

It is mentioned "Note: The output of this function should be used. If it is not, a warning will be logged or an error may be raised. To mark the output as used, call its .mark_used() method."

So, I was facing this error while using the "write()" method of the TensorArray.

tfa=tf.TensorArray(tf.float32, size=10)
tfa.write(1,10)

Which was later resolved when used in this way:

tfa=tf.TensorArray(tf.float32, size=10)

tfa.write(1,10).mark_used()
Answered By: Joseph J
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.