title: Using Queues to uniformly sample from multiple input files
body: <p>I have one serialized file for each class in my dataset. I would like to use queues to load up each of these files and then place them in a RandomShuffleQueue that will pull them off so I get a random mix of examples from each class. I thought this code would work.</p>
  
  <p>In this example each file has 10 examples.</p>
  
  <pre class="lang-py prettyprint-override"><code>filenames = ["a", "b", ...]
  
  with self.test_session() as sess:
    # for each file open a queue and get that
    # queue's results. 
    strings = []
    rq = tf.RandomShuffleQueue(1000, 10, [tf.string], shapes=())
    for filename in filenames:
      q = tf.FIFOQueue(99, [tf.string], shapes=())
      q.enqueue([filename]).run()
      q.close().run()
      # read_string just pulls a string from the file
      key, out_string = input_data.read_string(q, IMAGE_SIZE, CHANNELS, LABEL_BYTES)
      strings.append(out_string)
  
      rq.enqueue([out_string]).run()
  
    rq.close().run()
    qs = rq.dequeue()
    label, image = input_data.string_to_data(qs, IMAGE_SIZE, CHANNELS, LABEL_BYTES)
    for i in range(11):
      l, im = sess.run([label, image])
      print("L: {}".format(l)
  </code></pre>
  
  <p>This works fine for 10 calls, but on the 11th it says that the queue is empty. </p>
  
  <p>I believe this is due to a misunderstanding on my part of what these queues operate on. I add 10 variables to the <code>RandomShuffleQueue</code>, but each of those variables is itself pulling from a queue, so I assumed the queue would not be emptied until each of the file queues was empty. </p>
  
  <p>What am I doing wrong here?</p>