2016-08-26 51 views
0

我遇到了代码顺序影响最终结果的问题。起初,代码起作用。在移动一条线后,张量流产生一个错误。代码顺序影响最终结果

例如,

工作版本:

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_optop_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) 

有没有人有关于此问题的可能原因的想法?或者有关如何调试的任何想法?

+0

您正在运行哪个版本的TensorFlow? – mrry

+0

我使用预先安装在集群中的张量流。我怎样才能知道这个版本? – denru

+0

最简单的方法是运行命令'python -c'import tensorflow as tf; print tf .__ version __''。 – mrry

回答

1

听起来好像你患了bug,这是在TensorFlow 0.9.0发布后修复的。在该版本(及更早版本)中,TensorFlow遇到竞态条件,如果您在队列运行程序(或其他调用sess.run()的线程)启动后修改了图形,则会导致不可恢复的错误。 0.9.0版本中的唯一解决方法是启动 队列运行程序(即代码中的image_producer之后图形已完全构建。

+0

谢谢。我会试着要求管理员将其升级到0.10,然后检查这个问题是否解决。 – denru