(vocab_filename,
                              encoder_type,
                              max_input_len,
                              max_target_len,
                              mode,
                              length_bucket_size=0,
                              length_bucket_start_id=_LENGTH_BUCKET_START_ID,
                              length_bucket_max_id=_LENGTH_BUCKET_MAX_ID,
                              add_task_id=False,
                              task_start_id=_TASK_START_ID)
return parser, shapes
Parse TFexamples supervised pair of raw strings.
Parse TFexamples supervised pair of raw strings.
Parse TFexamples supervised pair of raw strings .
def supervised_strings_parser(vocab_filename,
                              encoder_type,
                              max_input_len,
                              max_target_len,
                              mode,
                              length_bucket_size=0,
                              length_bucket_start_id=_LENGTH_BUCKET_START_ID,
                              length_bucket_max_id=_LENGTH_BUCKET_MAX_ID,
                              add_task_id=False,
                              task_start_id=_TASK_START_ID):
  """Parse TFexamples supervised pair of raw strings."""
  del mode  # Unused.

  def parser(input_dic):
    """Parser for string dict."""
    inputs = parsing_ops.encode(
        tf.reshape(input_dic["inputs"], [1]), max_input_len, vocab_filename,
        encoder_type)
    targets = parsing_ops.encode(
        tf.reshape(input_dic["targets"], [1]), max_target_len, vocab_filename,
        encoder_type)
    inputs = utils.add_length_bucket_id(inputs, targets, length_bucket_size,
                                        length_bucket_start_id,
                                        length_bucket_max_id)
    if add_task_id:
      inputs = utils.add_task_id(inputs, task_start_id + input_dic["task_id"])
    return {"inputs": inputs, "targets": targets}

  shapes = {"inputs": [max_input_len], "targets": [max_target_len]}
  return parser, shapes
def supervised_strings_parser ( vocab_filename , encoder_type , max_input_len , max_target_len , mode , length_bucket_size = 0 , length_bucket_start_id = _LENGTH_BUCKET_START_ID , length_bucket_max_id = _LENGTH_BUCKET_MAX_ID , add_task_id = False , task_start_id = _TASK_START_ID ) : del mode # Unused. def parser ( input_dic ) : """Parser for string dict.""" inputs = parsing_ops . encode ( tf . reshape ( input_dic [ "inputs" ] , [ 1 ] ) , max_input_len , vocab_filename , encoder_type ) targets = parsing_ops . encode ( tf . reshape ( input_dic [ "targets" ] , [ 1 ] ) , max_target_len , vocab_filename , encoder_type ) inputs = utils . add_length_bucket_id ( inputs , targets , length_bucket_size , length_bucket_start_id , length_bucket_max_id ) if add_task_id : inputs = utils . add_task_id ( inputs , task_start_id + input_dic [ "task_id" ] ) return { "inputs" : inputs , "targets" : targets } shapes = { "inputs" : [ max_input_len ] , "targets" : [ max_target_len ] } return parser , shapes