コード例 #1
0
def edit_distance(targets, target_seq_length, predictions_sequence,
                  predictions_seq_length):
    predicts = to_sparse(predictions_sequence, predictions_seq_length,
                         tf.shape(predictions_sequence)[1])
    labels = to_sparse(targets, target_seq_length, tf.shape(targets)[1])
    edit_distance = tf.edit_distance(predicts, labels)
    mean_edit_distance = tf.reduce_mean(edit_distance)
    return edit_distance, mean_edit_distance
コード例 #2
0
def edit_distance(targets, target_seq_length, predictions_sequence,
                  predictions_seq_length, output_feature_name):
    predicts = to_sparse(predictions_sequence, predictions_seq_length,
                         tf.shape(predictions_sequence)[1])
    labels = to_sparse(targets, target_seq_length, tf.shape(targets)[1])
    edit_distance = tf.edit_distance(
        predicts, labels, name='edit_distance_{}'.format(output_feature_name))
    mean_edit_distance = tf.reduce_mean(
        edit_distance,
        name='mean_edit_distance_{}'.format(output_feature_name))
    return edit_distance, mean_edit_distance