我遇到了代码顺序影响最终结果的问题。起初,代码起作用。在移动一条线后,张量流产生一个错误。代码顺序影响最终结果
例如,
工作版本:
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