【问题标题】:Input Queue not responding TensorFlow program hanging输入队列没有响应 TensorFlow 程序挂起
【发布时间】:2017-02-18 03:45:40
【问题描述】:

我目前正在尝试训练神经网络。我有一组文件名及其相应的标签。但是,我在尝试训练网络时遇到了问题。

image_list, label_list = readImageLables()

images = ops.convert_to_tensor(image_list, dtype=dtypes.string)
labels = ops.convert_to_tensor(label_list, dtype=dtypes.int32)

with tf.Session() as sess:
    init_op = tf.initialize_all_variables()
    sess.run(init_op)
    coord = tf.train.Coordinator()
    threads = tf.train.start_queue_runners(sess=sess, coord=coord)
    for epoch in range(hm_epochs):
        epoch_loss = 0
        for _ in range(int(7685/batch_size)):
            print(labels.eval())
            filename_queue = tf.train.slice_input_producer([images,labels], num_epochs=10, shuffle=True)
            image,label = read_images_from_disk(filename_queue)
            print(image.eval())
            epoch_x, epoch_y = tf.train.batch([image, label], batch_size=batch_size)
            print("wait what")
            #imgs, lbls = epoch_x.eval(), epoch_y.eval()
            _, c = sess.run([optimizer, cost], feed_dict={x: epoch_x.eval(), y: epoch_y.eval()})
            epoch_loss += c

        print('Epoch', epoch, 'completed out of',hm_epochs,'loss:',epoch_loss)

在我尝试打印图像数据的那一行,程序挂起。即使删除了这一行,程序也会挂在我提供此数据的最后一个 sess.run 调用上。我已经初始化了队列运行器、协调器等。但是,我感觉 filename_queue 有问题。我在 tf.train.slice_input_producer 行中缺少什么吗?也是程序挂起还是加载需要一段时间。加载一个批次大小为 100 且图像为 80 x 70 的 epoch 通常需要多长时间?

【问题讨论】:

  • 您是否看到该程序占用了topnvidia-smi 上的任何资源?

标签: machine-learning tensorflow neural-network conv-neural-network


【解决方案1】:

这看起来像是我打开的一个问题。在提供数据时,输入队列运行器挂起。这是因为你必须启动它。

issue,我们有:

引用:RudrakshTuwani
对于其他为此苦苦挣扎的人,请阅读文档 提到的。对于懒惰的人:

init = tf.global_variables_initializer()
sess.run(init)
threads = tf.train.start_queue_runners()
print(sess.run(name_of_output_tensor))

还有:

发件人:girving
您可能需要启动队列运行器。请参阅文档 在https://www.tensorflow.org/versions/r0.11/how_tos/threading_and_queues/index.html

希望对您有所帮助!
pltrdy


请注意,就我而言,我感到困惑是因为 original code 正在使用:

sv = tf.train.Supervisor(logdir=FLAGS.save_path)
    with sv.managed_session() as session:

代替我的(和你的):

with tf.Session() as session:

第一个实际上隐式启动队列运行器。

【讨论】:

    猜你喜欢
    • 2011-07-27
    • 1970-01-01
    • 2014-03-05
    • 2022-12-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多