I have data that comes into my graph through queue runners, after I switched from the handy but speed-inferior placeholders.
After each training epoch, I wish to run a validation pass. Other than the the training pass, the validation pass uses different data, no augmentation and no shuffling.
The question is simple: how do I toggle these things?
A few observations:
shuffle
option in the string_input_producer
through a tf.placeholder
boolean.placeholder
to seperate the training from the validation data. These in turn, do not use the superior queue runners.tf.cond()
here i would test for a is_training
tf.placeholder
boolean that i pass through the feed_dict
. Is this solution the most optimal? How expensive is this tf.conf()
method?The method that works well for me is to use tf.placeholder_with_default
:
images_train, labels_train = train_data_pipeline(fnlist_train, ref_grid) images_val, labels_val = val_data_pipeline(fnlist_val, ref_grid) images = tf.placeholder_with_default(images_train, shape=[None, FLAGS.nx_image, FLAGS.ny_image, FLAGS.nz_image]) labels = tf.placeholder_with_default(labels_train, shape=[None, label_length])
During training, images
and labels
come directly from the training queue. For the intermittent validation steps I feed images
and labels
through a feed_dict in a call tosess.run()
. The only slight hack is that is that the validation data are also tensors from a queue and feed_dict doesn't accept tensors, so I call sess.run([images_val, labels_val])
first to get numpy values and then use them in the feed_dict. Seems to work well and there is minimal delay from the tensor==>numpy==>tensor conversion, which only occurs during validation anyway.
And for your case where the validation data have separate processing requirements, this can be handled when you set up the separate validation queue and processing flow to it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With