(self, input_pattern, shuffle_files)
return dataset, num_examples
Build dataset.

    Args:
      input_pattern: input patterns have more than two parts separated by
        hyphens. The first part is the name of tfds, could be xxx/yyy. The
        second part is split type among train, validation, or test. Rest are the
        key arguments.
        For example a valid dataset would be:
          big_patent/all-train-shard_100-take_200
      shuffle_files: whether to shuffle files list.

    Returns:
      Tuple of (tf.data.Dataset, number_of_examples)
Build dataset.
Build dataset .
def build(self, input_pattern, shuffle_files):
    """Build dataset.

    Args:
      input_pattern: input patterns have more than two parts separated by
        hyphens. The first part is the name of tfds, could be xxx/yyy. The
        second part is split type among train, validation, or test. Rest are the
        key arguments.
        For example a valid dataset would be:
          big_patent/all-train-shard_100-take_200
      shuffle_files: whether to shuffle files list.

    Returns:
      Tuple of (tf.data.Dataset, number_of_examples)
    """
    args = input_pattern.split("-")
    build_name, split = args[0:2]
    kwargs = [seg.split("_") for seg in args[2:]]
    kwargs = {k: v for k, v in kwargs}

    if split not in ["train", "validation", "test"]:
      raise ValueError("Split type %s is not supported. Supported types are: "
                       "train, validation, test." % split)
    dataset, num_examples = self.load(build_name, split, shuffle_files)
    dataset = self.transform(dataset)

    if "shard" in kwargs:
      dataset = dataset.shard(int(kwargs.pop("shard")), 0)
    if "take" in kwargs:
      num_examples = int(kwargs.pop("take"))
      dataset = dataset.take(num_examples)
      if num_examples <= 10000:
        dataset = dataset.cache()
    if kwargs:
      raise ValueError("Unused keys: %s" % ",".join(kwargs.keys()))

    num_examples = int(num_examples)
    logging.info("Number of examples for config %s %s is %d", build_name, split,
                 num_examples)
    return dataset, num_examples
def build ( self , input_pattern , shuffle_files ) : args = input_pattern . split ( "-" ) build_name , split = args [ 0 : 2 ] kwargs = [ seg . split ( "_" ) for seg in args [ 2 : ] ] kwargs = { k : v for k , v in kwargs } if split not in [ "train" , "validation" , "test" ] : raise ValueError ( "Split type %s is not supported. Supported types are: " "train, validation, test." % split ) dataset , num_examples = self . load ( build_name , split , shuffle_files ) dataset = self . transform ( dataset ) if "shard" in kwargs : dataset = dataset . shard ( int ( kwargs . pop ( "shard" ) ) , 0 ) if "take" in kwargs : num_examples = int ( kwargs . pop ( "take" ) ) dataset = dataset . take ( num_examples ) if num_examples <= 10000 : dataset = dataset . cache ( ) if kwargs : raise ValueError ( "Unused keys: %s" % "," . join ( kwargs . keys ( ) ) ) num_examples = int ( num_examples ) logging . info ( "Number of examples for config %s %s is %d" , build_name , split , num_examples ) return dataset , num_examples