(parser_fn,
                 input_pattern,
                 mode,
                 prefetch=True,
                 drop_remainder=True,
                 parallelism=32)
return input_fn
Estimator input_fn for TFRecords.
Estimator input_fn for TFRecords.
Estimator input_fn for TFRecords .
def get_input_fn(parser_fn,
                 input_pattern,
                 mode,
                 prefetch=True,
                 drop_remainder=True,
                 parallelism=32):
  """Estimator input_fn for TFRecords."""

  # Parser can support any input types -- e.g. tfexamples, or arbitrary
  # protobufs. The parser_fn also returns expected shapes, as a map from
  # feature_name to feature_shape (list of ints).
  parser, shapes = parser_fn(mode=mode)
  training = mode == tf.estimator.ModeKeys.TRAIN
  if not training:
    parallelism = 1

  def input_fn(params):
    """Input function."""
    dataset = all_datasets.get_dataset(input_pattern, training)
    dataset = dataset.map(parser, num_parallel_calls=parallelism)
    dataset = dataset.unbatch()
    if training:
      dataset = dataset.shuffle(10000)
      dataset = dataset.repeat()
    dataset = dataset.padded_batch(
        params["batch_size"],
        padded_shapes=shapes,
        drop_remainder=drop_remainder)
    if prefetch:
      dataset = dataset.prefetch(512)
    return dataset

  return input_fn
def get_input_fn ( parser_fn , input_pattern , mode , prefetch = True , drop_remainder = True , parallelism = 32 ) : # Parser can support any input types -- e.g. tfexamples, or arbitrary # protobufs. The parser_fn also returns expected shapes, as a map from # feature_name to feature_shape (list of ints). parser , shapes = parser_fn ( mode = mode ) training = mode == tf . estimator . ModeKeys . TRAIN if not training : parallelism = 1 def input_fn ( params ) : """Input function.""" dataset = all_datasets . get_dataset ( input_pattern , training ) dataset = dataset . map ( parser , num_parallel_calls = parallelism ) dataset = dataset . unbatch ( ) if training : dataset = dataset . shuffle ( 10000 ) dataset = dataset . repeat ( ) dataset = dataset . padded_batch ( params [ "batch_size" ] , padded_shapes = shapes , drop_remainder = drop_remainder ) if prefetch : dataset = dataset . prefetch ( 512 ) return dataset return input_fn