(labels, blank_index, num_class=None)
return labels
Change the value of blank_label elements from blank_index to num_class - 1
Change the value of blank_label elements from blank_index to num_class - 1
Change the value of blank_label elements from blank_index to num_class - 1
def labels_blankid_to_last(labels, blank_index, num_class=None):
  ''' Change the value of blank_label elements from blank_index to num_class - 1'''
  assert num_class is not None, 'The num_class should not be None!'

  labels = transform_preprocess(
      labels=labels, blank_index=blank_index, num_class=num_class)

  labels_values = labels.values
  labels_num_class = tf.zeros_like(labels_values, dtype=tf.int32) + num_class
  labels_values_change_blank = tf.where(
      tf.equal(labels_values, blank_index), labels_num_class, labels_values)
  labels_values = tf.where(labels_values_change_blank < blank_index,
                           labels_values_change_blank,
                           labels_values_change_blank - 1)

  labels = tf.SparseTensor(
      indices=labels.indices,
      values=labels_values,
      dense_shape=labels.dense_shape)
  return labels
def labels_blankid_to_last ( labels , blank_index , num_class = None ) : assert num_class is not None , 'The num_class should not be None!' labels = transform_preprocess ( labels = labels , blank_index = blank_index , num_class = num_class ) labels_values = labels . values labels_num_class = tf . zeros_like ( labels_values , dtype = tf . int32 ) + num_class labels_values_change_blank = tf . where ( tf . equal ( labels_values , blank_index ) , labels_num_class , labels_values ) labels_values = tf . where ( labels_values_change_blank < blank_index , labels_values_change_blank , labels_values_change_blank - 1 ) labels = tf . SparseTensor ( indices = labels . indices , values = labels_values , dense_shape = labels . dense_shape ) return labels