Code order influences the final result
<p>I encountered a problem that the code order influences the final result. At first, the code works. After I move one line, tensorflow generates an error.</p>

<p>For example,  </p>

<p><strong>working version:</strong></p>

<pre><code>probs = net.get_output()
label_node = tf.placeholder(tf.int32, name='label_node')
top_1_op = tf.nn.in_top_k(probs, label_node, 1)
top_5_op = tf.nn.in_top_k(probs, label_node, 5)
threads = image_producer.start(session=sess, coordinator=coordinator)
for (labels, images) in image_producer.batches(sess):
    top_1_result, top_5_result = sess.run([top_1_op, top_5_op],
                                    feed_dict={input_node: images, label_node: labels})  
</code></pre>

<p><strong>Non-working version:</strong></p>

<pre><code>threads = image_producer.start(session=sess, coordinator=coordinator)   # move here
probs = net.get_output()
label_node = tf.placeholder(tf.int32, name='label_node')
top_1_op = tf.nn.in_top_k(probs, label_node, 1)
top_5_op = tf.nn.in_top_k(probs, label_node, 5)
for (labels, images) in image_producer.batches(sess):
    top_1_result, top_5_result = sess.run([top_1_op, top_5_op],
                                    feed_dict={input_node: images, label_node: labels})
</code></pre>

<p><strong>Tensorflow generates an error</strong> </p>

<pre><code>"tensorflow.python.framework.errors.NotFoundError: FeedInputs: unable to find feed output label_node:0".  
</code></pre>

<p>As you can see, tensorflow should be able to find "label_node:0". Actually, tensorflow cannot find <code>top_1_op</code> and <code>top_5_op</code> either.</p>

<p>The content of <code>image_producer.start</code> is something similar to:</p>

<pre><code>op_A = ...
queue_runner = tf.train.QueueRunner(queue_B, [op_B] * num_concurrent)
session.run(op_A)
t = queue_runner.create_threads(session, coord=coordinator, start=True)
</code></pre>

<p>A more strange thing is that in the non-workable version, after I add two lines in <code>image_producer.start</code>, the code works again. For example, <code>image_producer.start</code> becomes</p>

<pre><code>op_C = ...  # new
session.run(op_C)  # new
op_A = ...
queue_runner = tf.train.QueueRunner(queue_B, [op_B] * num_concurrent)
session.run(op_A)
t = queue_runner.create_threads(session, coord=coordinator, start=True)
</code></pre>

<p>Does anyone have an idea about possible causes of this problem? Or any idea about how to debug this?</p>