(self, split, ds, file_pattern=None)
return ds
Replaces the labels in the dataset with labels from separate files.

    This functionality is used if one wants to either replace the labels with
    soft labels (i.e. softmax over the logits) or label the instances with
    a new classifier.

    Args:
      split: Dataset split (e.g. train/test/validation).
      ds: The underlying TFDS object.
      file_pattern: Path to the replacement files.

    Returns:
      An instance of tf.data.Dataset with the updated labels.
Replaces the labels in the dataset with labels from separate files.
Replaces the labels in the dataset with labels from separate files .
def _replace_labels(self, split, ds, file_pattern=None):
    """Replaces the labels in the dataset with labels from separate files.

    This functionality is used if one wants to either replace the labels with
    soft labels (i.e. softmax over the logits) or label the instances with
    a new classifier.

    Args:
      split: Dataset split (e.g. train/test/validation).
      ds: The underlying TFDS object.
      file_pattern: Path to the replacement files.

    Returns:
      An instance of tf.data.Dataset with the updated labels.
    """
    if not file_pattern:
      return ds
    file_pattern = file_pattern.format(split=split)
    logging.warning("Using labels from %s for split %s.", file_pattern, split)
    label_ds = tf.data.Dataset.list_files(file_pattern, shuffle=False)
    label_ds = label_ds.interleave(
        tf.data.TFRecordDataset,
        cycle_length=FLAGS.data_reading_num_threads)
    ds = tf.data.Dataset.zip((ds, label_ds)).map(self._replace_label)
    return ds
def _replace_labels ( self , split , ds , file_pattern = None ) : if not file_pattern : return ds file_pattern = file_pattern . format ( split = split ) logging . warning ( "Using labels from %s for split %s." , file_pattern , split ) label_ds = tf . data . Dataset . list_files ( file_pattern , shuffle = False ) label_ds = label_ds . interleave ( tf . data . TFRecordDataset , cycle_length = FLAGS . data_reading_num_threads ) ds = tf . data . Dataset . zip ( ( ds , label_ds ) ) . map ( self . _replace_label ) return ds