def input_fn(self):
    'Input function which provides a single batch for train or eval.\n\n    Returns:\n      A `tf.data.Dataset` object.\n    '
    if (self.data_dir is None):
        tf.logging.info('Using fake input.')
        return self.input_fn_null()
    file_pattern = os.path.join(self.data_dir, ('train-*' if self.is_training else 'validation-*'))
    dataset = tf.data.Dataset.list_files(file_pattern, shuffle=self.is_training)
    if self.is_training:
        dataset = dataset.repeat()

    def fetch_dataset(filename):
        buffer_size = ((8 * 1024) * 1024)
        dataset = tf.data.TFRecordDataset(filename, buffer_size=buffer_size)
        return dataset
    dataset = dataset.apply(tf.contrib.data.parallel_interleave(fetch_dataset, cycle_length=16, sloppy=True))
    dataset = dataset.shuffle(1024)
    dataset = dataset.apply(tf.contrib.data.map_and_batch(self.dataset_parser, batch_size=self.batch_size, num_parallel_batches=2, drop_remainder=True))
    dataset = dataset.prefetch(tf.contrib.data.AUTOTUNE)
    return dataset
Input function which provides a single batch for train or eval.

Returns:
  A `tf.data.Dataset` object.
def input_fn(self):
    'Input function which provides a single batch for train or eval.\n\n    Returns:\n      A `tf.data.Dataset` object.\n    '
    if (self.data_dir is None):
        tf.logging.info('Using fake input.')
        return self.input_fn_null()
    file_pattern = os.path.join(self.data_dir, ('train-*' if self.is_training else 'validation-*'))
    dataset = tf.data.Dataset.list_files(file_pattern, shuffle=self.is_training)
    if self.is_training:
        dataset = dataset.repeat()

    def fetch_dataset(filename):
        buffer_size = ((8 * 1024) * 1024)
        dataset = tf.data.TFRecordDataset(filename, buffer_size=buffer_size)
        return dataset
    dataset = dataset.apply(tf.contrib.data.parallel_interleave(fetch_dataset, cycle_length=16, sloppy=True))
    dataset = dataset.shuffle(1024)
    dataset = dataset.apply(tf.contrib.data.map_and_batch(self.dataset_parser, batch_size=self.batch_size, num_parallel_batches=2, drop_remainder=True))
    dataset = dataset.prefetch(tf.contrib.data.AUTOTUNE)
    return dataset