Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can a TensorFlow queue be reopened after it is closed?

I would like to enqueue items, close the queue to ensure that other sessions will dequeue all remaining items, then reopen it later for the next epoch. Is this possible?

q = tf.FIFOQueue(...)
close_q = q.close()
reopen_q = #???

with tf.Session([...]) as sess:
    [...]
    sess.run(close_q)
    [...]
    sess.run(reopen_q)
like image 367
MiniQuark Avatar asked Aug 29 '16 10:08

MiniQuark


1 Answers

There's no way to re-open a closed queue, but (only if you are using multiple sessions) there is a workaround::

  1. Create your queue in a with tf.container(name): block that wraps only the queues, and where name is not used for any other tf.container() blocks.

  2. Before you want to reopen the queue, call tf.Session.reset(..., [name]), where name is the name of the container you created in step 1. This will cause the queue to be recreated on its next use, and it will be in the opened state.

like image 99
mrry Avatar answered Sep 20 '22 03:09

mrry