(logits, sequence_length, blank_id=None)
return logits, sequence_length_return, blank_id
Moves the blank_label cloumn to the end of the logit matrix,
    and adjust the rank of sequence_length to 1
    param: logits, (B, T, C), output of ctc asr model
    param: sequence_length, (B, 1), sequence lengths
    param: blank_id, None, default blank_id is 0, same to espnet.
    return: logits_return, (T, B, C)
            sequence_length_return, (B)
Moves the blank_label cloumn to the end of the logit matrix,
    and adjust the rank of sequence_length to 1
    param: logits, (B, T, C), output of ctc asr model
    param: sequence_length, (B, 1), sequence lengths
    param: blank_id, None, default blank_id is 0, same to espnet.
    return: logits_return, (T, B, C)
            sequence_length_return, (B)
Moves the blank_label cloumn to the end of the logit matrix and adjust the rank of sequence_length to 1 param : logits ( B T C ) output of ctc asr model param : sequence_length ( B 1 ) sequence lengths param : blank_id None default blank_id is 0 same to espnet . return : logits_return ( T B C ) sequence_length_return ( B )
def ctc_decode_blankid_to_last(logits, sequence_length, blank_id=None):
  '''
    Moves the blank_label cloumn to the end of the logit matrix,
    and adjust the rank of sequence_length to 1
    param: logits, (B, T, C), output of ctc asr model
    param: sequence_length, (B, 1), sequence lengths
    param: blank_id, None, default blank_id is 0, same to espnet.
    return: logits_return, (T, B, C)
            sequence_length_return, (B)
    '''

  logits = tf.transpose(logits, [1, 0, 2])
  #blank_id=0 is used as default in Espnet,
  #while blank_id is set as C-1 in tf.nn.ctc_decoder
  if blank_id is None:
    blank_id = 0
  logits = ctc_utils.logits_blankid_to_last(logits=logits, blank_index=blank_id)

  sequence_length_return = tf.cond(
      pred=tf.equal(tf.rank(sequence_length), 1),
      true_fn=lambda: sequence_length,
      false_fn=lambda: tf.squeeze(sequence_length),
  )

  return logits, sequence_length_return, blank_id
def ctc_decode_blankid_to_last ( logits , sequence_length , blank_id = None ) : logits = tf . transpose ( logits , [ 1 , 0 , 2 ] ) #blank_id=0 is used as default in Espnet, #while blank_id is set as C-1 in tf.nn.ctc_decoder if blank_id is None : blank_id = 0 logits = ctc_utils . logits_blankid_to_last ( logits = logits , blank_index = blank_id ) sequence_length_return = tf . cond ( pred = tf . equal ( tf . rank ( sequence_length ) , 1 ) , true_fn = lambda : sequence_length , false_fn = lambda : tf . squeeze ( sequence_length ) , ) return logits , sequence_length_return , blank_id