machine learning - Tensorflow - Using batching to form a validation set -


i'm attempting use tensorflow's batching system, detailed here https://www.tensorflow.org/versions/master/how_tos/reading_data/index.html make predictions using model trained previously. @ moment have set batch size use in tf.train.batch equal size of data set want make predictions over.

however, want create validation set test predictions , avoid overfitting.

is there way separate validation set training data using batching system or way use placeholders?

below sample of code responsible training. it:

  • reads data csv file, converts data tensors
  • passes tensors tf.train.shuffle_batch train

    def input_pipeline(filename_list, batch_size, capacity): filename_queue = tf.train.string_input_producer(filename_list,num_epochs=none) reader = tf.textlinereader() key, value = reader.read(filename_queue)

    # defaults force key value , label int, others float. record_defaults = [[1]]+[[46]]+[[1.0] in range(436)] # reads in single row csv , outputs list of scalars. csv_list = tf.decode_csv(value, record_defaults=record_defaults) # packs different columns separate feature tensors. location = tf.pack(csv_list[2:4]) bbox = tf.pack(csv_list[5:8]) pix_feats = tf.pack(csv_list[9:]) onehot = tf.one_hot(csv_list[1], depth=98) keep_prob = 0.5   # creates batches of images , labels. image_batch, label_batch = tf.train.shuffle_batch(     [pix_feats, onehot],      batch_size=batch_size, num_threads=4, capacity=capacity, min_after_dequeue=30000)  return image_batch, label_batch 

i'm not sure record_defaults.

so there's couple of ways it. have 2 different "shuffle_batch" 1 take in training data , other take in validation data. call run 1 or other.

train_loss = train(train_set) val_loss = val(val_set)  sess.run([train_loss]) # or sess.run([val_loss]) 

placeholders alternative.


Comments

Popular posts from this blog

java - Jasper subreport showing only one entry from the JSON data source when embedded in the Title band -

mapreduce - Resource manager does not transit to active state from standby -

serialization - Convert Any type in scala to Array[Byte] and back -