In my tensorflor pipeline I am creating two batching queues: one for the examples (images) and one for the labels (integers), essentially in the same way that cifar10_input.py processes input:
<read files>
image = tf.image.decode_png(file_contents)
label = tf.string_to_number(label_str, out_type=tf.int32)
# Batch examples here into two queues.
image_batch, label_batch = tf.train.shuffle_batch(
[image, label], ... )
model = build_model(image_batch)
loss = build_loss(model, label_batch)
The model then takes the image queue as an input, and the loss evaluates the difference between the output of the model and the labels.
My worry is that if I evaluate only the model on a batch of images, the label queue will no longer be "aligned" and the two queues (images and labels) will diverge.
(model_output, ) = sess.run([model]) # Uses the image queue as input
(model_output, true_labels) = sess.run([model, label_batch]) # Are image/labels pairs valid?
How can I ensure the two queues stay synchronized, so that fetching an element from each will always return a correct image/label pair?