baselines/cifar/utils.py
def input_fn(ctx=None):
    """Returns a locally sharded (i.e., per-core) dataset batch."""
    if proportion == 1.0:
      dataset = tfds.load(
          name, split=split, data_dir=data_dir, as_supervised=True)
    else:
      new_name = '{}:3.*.*'.format(name)
      if split == tfds.Split.TRAIN:
        # use round instead of floor to resolve bug when e.g. using
        # proportion = 1 - 0.8 = 0.19999999
        new_split = 'train[:{}%]'.format(round(100 * proportion))
      elif split == tfds.Split.VALIDATION:
        new_split = 'train[-{}%:]'.format(round(100 * proportion))
      elif split == tfds.Split.TEST:
        new_split = 'test[:{}%]'.format(round(100 * proportion))
      else:
        raise ValueError('Provide valid split.')
      dataset = tfds.load(new_name, split=new_split, as_supervised=True)
    if split == tfds.Split.TRAIN or repeat:
      dataset = dataset.shuffle(buffer_size=dataset_size).repeat()

    dataset = dataset.map(preprocess,
                          num_parallel_calls=tf.data.experimental.AUTOTUNE)
    dataset = dataset.batch(batch_size, drop_remainder=drop_remainder)
    dataset = dataset.prefetch(tf.data.experimental.AUTOTUNE)
    if ctx and ctx.num_input_pipelines > 1:
      dataset = dataset.shard(ctx.num_input_pipelines, ctx.input_pipeline_id)
    return dataset
Returns a locally sharded (i.e., per-core) dataset batch.
Returns a locally sharded  dataset batch.
Returns a locally sharded dataset batch .
def input_fn(ctx=None):
    if proportion == 1.0:
      dataset = tfds.load(
          name, split=split, data_dir=data_dir, as_supervised=True)
    else:
      new_name = '{}:3.*.*'.format(name)
      if split == tfds.Split.TRAIN:
        new_split = 'train[:{}%]'.format(round(100 * proportion))
      elif split == tfds.Split.VALIDATION:
        new_split = 'train[-{}%:]'.format(round(100 * proportion))
      elif split == tfds.Split.TEST:
        new_split = 'test[:{}%]'.format(round(100 * proportion))
      else:
        raise ValueError('Provide valid split.')
      dataset = tfds.load(new_name, split=new_split, as_supervised=True)
    if split == tfds.Split.TRAIN or repeat:
      dataset = dataset.shuffle(buffer_size=dataset_size).repeat()
    dataset = dataset.map(preprocess,
                          num_parallel_calls=tf.data.experimental.AUTOTUNE)
    dataset = dataset.batch(batch_size, drop_remainder=drop_remainder)
    dataset = dataset.prefetch(tf.data.experimental.AUTOTUNE)
    if ctx and ctx.num_input_pipelines > 1:
      dataset = dataset.shard(ctx.num_input_pipelines, ctx.input_pipeline_id)
    return dataset
def input_fn ( ctx = None ) : if proportion == 1.0 : dataset = tfds . load ( name , split = split , data_dir = data_dir , as_supervised = True ) else : new_name = '{}:3.*.*' . format ( name ) if split == tfds . Split . TRAIN : new_split = 'train[:{}%]' . format ( round ( 100 * proportion ) ) elif split == tfds . Split . VALIDATION : new_split = 'train[-{}%:]' . format ( round ( 100 * proportion ) ) elif split == tfds . Split . TEST : new_split = 'test[:{}%]' . format ( round ( 100 * proportion ) ) else : raise ValueError ( 'Provide valid split.' ) dataset = tfds . load ( new_name , split = new_split , as_supervised = True ) if split == tfds . Split . TRAIN or repeat : dataset = dataset . shuffle ( buffer_size = dataset_size ) . repeat ( ) dataset = dataset . map ( preprocess , num_parallel_calls = tf . data . experimental . AUTOTUNE ) dataset = dataset . batch ( batch_size , drop_remainder = drop_remainder ) dataset = dataset . prefetch ( tf . data . experimental . AUTOTUNE ) if ctx and ctx . num_input_pipelines > 1 : dataset = dataset . shard ( ctx . num_input_pipelines , ctx . input_pipeline_id ) return dataset
Returns a locally sharded (i.e., per-core) dataset batch.
Returns a locally sharded ( i . e . per - core ) dataset batch .
"""Returns a locally sharded (i.e., per-core) dataset batch.""" # use round instead of floor to resolve bug when e.g. using # proportion = 1 - 0.8 = 0.19999999
ctx