(label_ds, config, output_index=None)
return label_ds
process one-label data set.
process one-label data set.
process one - label data set .
def process_one_label_dataset(label_ds, config, output_index=None):
  """process one-label data set."""

  logging.info("Loading one label dataset...")
  num_parallel_calls = config["data"]["task"]["num_parallel_calls"]
  classes = config["data"]["task"]["classes"]
  if isinstance(classes, list):
    if output_index is None or output_index not in range(len(classes)):
      raise IndexError("output_index:{} not in the range of classes length: "
                       "{}!".format(output_index, len(classes)))
    num_classes = classes[output_index]["num_classes"]
    label_vocab_file_path = config["data"]["task"]["label_vocab"][output_index]
  else:
    num_classes = classes["num_classes"]
    label_vocab_file_path = config["data"]["task"]["label_vocab"]

  label_ds = label_ds.map(
      lambda x: tokenize_label(
          x, maxlen=1, label_vocab_file_path=label_vocab_file_path, pad_id=0),
      num_parallel_calls=num_parallel_calls)

  label_ds = label_ds.map(
      lambda l: tf.one_hot(l, num_classes, dtype=tf.int32),
      num_parallel_calls=num_parallel_calls)

  label_ds = label_ds.map(tf.squeeze, num_parallel_calls=num_parallel_calls)

  return label_ds
def process_one_label_dataset ( label_ds , config , output_index = None ) : logging . info ( "Loading one label dataset..." ) num_parallel_calls = config [ "data" ] [ "task" ] [ "num_parallel_calls" ] classes = config [ "data" ] [ "task" ] [ "classes" ] if isinstance ( classes , list ) : if output_index is None or output_index not in range ( len ( classes ) ) : raise IndexError ( "output_index:{} not in the range of classes length: " "{}!" . format ( output_index , len ( classes ) ) ) num_classes = classes [ output_index ] [ "num_classes" ] label_vocab_file_path = config [ "data" ] [ "task" ] [ "label_vocab" ] [ output_index ] else : num_classes = classes [ "num_classes" ] label_vocab_file_path = config [ "data" ] [ "task" ] [ "label_vocab" ] label_ds = label_ds . map ( lambda x : tokenize_label ( x , maxlen = 1 , label_vocab_file_path = label_vocab_file_path , pad_id = 0 ) , num_parallel_calls = num_parallel_calls ) label_ds = label_ds . map ( lambda l : tf . one_hot ( l , num_classes , dtype = tf . int32 ) , num_parallel_calls = num_parallel_calls ) label_ds = label_ds . map ( tf . squeeze , num_parallel_calls = num_parallel_calls ) return label_ds