Working with tensorflow's shuffle_batch method
Question: I'm experimenting with [tensorflow](https://www.tensorflow.org/) and I'm
trying to read from a `csv` file and print out a batch of its data via
`shuffle_batch`. I've gone throw the [decode_csv
docs](https://www.tensorflow.org/versions/r0.9/api_docs/python/io_ops.html#decode_csv)
and the [shuffle_batch
docs](https://www.tensorflow.org/versions/r0.9/api_docs/python/io_ops.html#shuffle_batch),
but I'm still unable to get it working.

Here's what I have: import tensorflow as tf

    
    
    sess = tf.InteractiveSession()
    
    filename_queue = tf.train.string_input_producer(
        ["./data/train.csv"], num_epochs=1, shuffle=True) # total record count in csv is 30K
    reader = tf.TextLineReader()
    key, value = reader.read(filename_queue)
    
    record_defaults = [["1"], ["2"]] # irrelevant for this discussion
    input, outcome = tf.decode_csv(value, record_defaults=record_defaults)
    
    min_after_dequeue = 1000
    batch_size = 10
    capacity = min_after_dequeue + 3 * batch_size
    
    example_batch = tf.train.shuffle_batch([outcome], batch_size, capacity, min_after_dequeue)
    coord = tf.train.Coordinator()
    tf.train.start_queue_runners(sess, coord=coord)
    example_batch.eval(session = sess)
    

Running this will generate this exception:

    
    
    OutOfRangeError: RandomShuffleQueue
        '_3_shuffle_batch_1/random_shuffle_queue' is closed 
        and has insufficient elements (requested 10, current size 0)
    

I'm not sure what the issue is. I have a feeling it's due to the session and
the way I'm handling it; I'm probably not doing it properly.


Answer: Try removing the `num_epochs=1` from your `string_input_producer` initializer.

