【问题标题】:Why calling a dequeue_op in the following code throw tensorflow.python.framework.errors.OutOfRangeError为什么在以下代码中调用 dequeue_op 会抛出 tensorflow.python.framework.errors.OutOfRangeError
【发布时间】:2016-02-12 13:21:37
【问题描述】:

在以下示例中,我从文件中读取数据,对其进行解码并使用 tf.train.shuffle_batch 创建一个批处理。我启动每个队列运行器线程,然后获取我的批处理。它会抛出 outOfRange 错误,就好像我的数据队列为空一样。我不明白为什么,因为我开始每个队列跑步者。

filename_queue = tf.train.string_input_producer(source,shuffle=True)

example, label = decode_and_transform(filename_queue, ....)
examples, labels = tf.train.shuffle_batch([example, label], ...)

init_var = tf.initialize_all_variables()

sess = tf.Session()
sess.run(init_var)
coord = tf.train.Coordinator()
threads = tf.train.start_queue_runners(coord=coord, sess=sess)

# throw out of range error
img, lab = sess.run([examples, labels])

【问题讨论】:

    标签: tensorflow


    【解决方案1】:

    意外tf.errors.OutOfRangeError 的最常见原因是将元素排入队列的操作之一失败。通过手动运行上游代码(并且不调用tf.train.start_queue_runners()

    # Runs the ops before `tf.train.shuffle_batch()`.
    example_val, label_val = sess.run([example, label])
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-03-13
      • 2019-01-09
      • 2014-06-19
      • 2021-01-10
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多