I have the following (shortened) code I am trying to run:
coord = tf.train.Coordinator()
threads = tf.train.start_queue_runners(sess=sess, coord=coord)
try:
while not coord.should_stop():
# Run some code.... (Reading some data from file 1)
coord_dev = tf.train.Coordinator()
threads_dev = tf.train.start_queue_runners(sess=sess, coord=coord_dev)
try:
while not coord_dev.should_stop():
# Run some other code.... (Reading data from file 2)
except tf.errors.OutOfRangeError:
print('Reached end of file 2')
finally:
coord_dev.request_stop()
coord_dev.join(threads_dev)
except tf.errors.OutOfRangeError:
print('Reached end of file 1')
finally:
coord.request_stop()
coord.join(threads)
What is supposed to happen above is that:
- File 1 is a csv file including training data for my neural network.
- File 2 includes dev set data.
While iterating over File 1 during training, I occasionally want to calculate cost an accuracy on dev set data (from File 2) as well. But when the inner loop finishes reading File 2, it obviously triggers the exception
"tf.errors.OutOfRangeError"
which causes my code to leave the outer loop as well. The exception of inner loop simply handled as the exception of outer loop too. But after finishing reading the File 2, I want my code continue training over File 1 in the outer loop.
(I have removed some details like num_epochs to train etc to simplify the readibility of the code)
Does any one have any suggestion regarding how to solve this problem? I am a bit new in this.
Thank you in advance!