我遇到了代碼順序影響最終結果的問題。起初,代碼起作用。在移動一條線後,張量流產生一個錯誤。代碼順序影響最終結果
例如,
工作版本:
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})
非工作版本:
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})
Tensorflow生成錯誤
"tensorflow.python.framework.errors.NotFoundError: FeedInputs: unable to find feed output label_node:0".
正如您所看到的,tensorflow應該能夠找到「label_node:0」。實際上,tensorflow也找不到top_1_op
和top_5_op
。
的image_producer.start
的內容類似於:
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)
一個更奇怪的是,在無法使用的版本,之後我在image_producer.start
添加兩行,代碼再次工作。例如,image_producer.start
變爲
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)
有沒有人有關於此問題的可能原因的想法?或者有關如何調試的任何想法?
您正在運行哪個版本的TensorFlow? – mrry
我使用預先安裝在集羣中的張量流。我怎樣才能知道這個版本? – denru
最簡單的方法是運行命令'python -c'import tensorflow as tf; print tf .__ version __''。 – mrry