(label_ds, config, output_index=None)
return label_ds
process multi-label data set.
process multi-label data set.
process multi - label data set .
def process_multi_label_dataset(label_ds, config, output_index=None):
  """process multi-label data set."""
  logging.info("Loading multi label dataset...")
  label_vocab_file_path = config["data"]["task"]["label_vocab"]
  num_parallel_calls = config["data"]["task"]["num_parallel_calls"]
  max_seq_len = config["data"]["task"]["max_seq_len"]

  label_vocab_file_path = config["data"]["task"]["label_vocab"]
  if isinstance(label_vocab_file_path, list):
    if output_index is None or output_index not in range(
        len(label_vocab_file_path)):
      raise IndexError("output_index:{} not in the range of classes length: "
                       "{}!".format(output_index, len(label_vocab_file_path)))
    label_vocab_file_path = label_vocab_file_path[output_index]

  else:
    label_vocab_file_path = label_vocab_file_path

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

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