def ctc_batch_cost(y_true, y_pred, input_length, label_length):
 label_length = tf.to_int32(tf.squeeze(label_length))
 input_length = tf.to_int32(tf.squeeze(input_length))
 sparse_labels = tf.to_int32(ctc_label_dense_to_sparse(y_true, label_length))
 y_pred = tf.log((tf.transpose(y_pred, perm=[1, 0, 2]) + 1e-08))
 return tf.expand_dims(ctc.ctc_loss(inputs=y_pred, labels=sparse_labels, sequence_length=input_length), 1)

def ctc_batch_cost ( y_true , y_pred , input_length , label_length ) : label_length = tf . to_int32 ( tf . squeeze ( label_length ) ) input_length = tf . to_int32 ( tf . squeeze ( input_length ) ) sparse_labels = tf . to_int32 ( ctc_label_dense_to_sparse ( y_true , label_length ) ) y_pred = tf . log ( ( tf . transpose ( y_pred , perm = [ 1 , 0 , 2 ] ) + 1e-08 ) ) return tf . expand_dims ( ctc . ctc_loss ( inputs = y_pred , labels = sparse_labels , sequence_length = input_length ) , 1 )
runs ctc loss algorithm on each batch element .