jrabary
jrabary

Reputation: 2441

Why calling a dequeue_op in the following code throw tensorflow.python.framework.errors.OutOfRangeError

In the following example I read a data from file, decode it and create a batch with tf.train.shuffle_batch. I start every queue runner threads and then fetch my batch. It throws outOfRange error as if my data queues are empty. I don't understand why since I start every queue runners.

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

Upvotes: 1

Views: 301

Answers (1)

mrry
mrry

Reputation: 126184

The most common reason for an unexpected tf.errors.OutOfRangeError is that one of the operations that enqueues elements to the queue has failed. Check whether one of the ops in your decode_and_transform() function is failing, by running the upstream code manually (and without calling tf.train.start_queue_runners():

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

Upvotes: 1

Related Questions