diff --git a/python/paddle/v2/fluid/evaluator.py b/python/paddle/v2/fluid/evaluator.py index 3ab0d65cd7b19479ea7fc35598c572ed88ccd17b..6206134de2afd371b4e901288dbab630aeb51e8f 100644 --- a/python/paddle/v2/fluid/evaluator.py +++ b/python/paddle/v2/fluid/evaluator.py @@ -226,14 +226,12 @@ class EditDistance(Evaluator): for epoch in PASS_NUM: distance_evaluator.reset(exe) for data in batches: - loss, sum_distance = exe.run(fetch_list=[cost] + distance_evaluator.metrics) - avg_distance = distance_evaluator.eval(exe) - pass_distance = distance_evaluator.eval(exe) + loss = exe.run(fetch_list=[cost]) + distance, sequence_error = distance_evaluator.eval(exe) In the above example: - 'sum_distance' is the sum of the batch's edit distance. - 'avg_distance' is the average of edit distance from the firt batch to the current batch. - 'pass_distance' is the average of edit distance from all the pass. + 'distance' is the average of the edit distance rate in a pass. + 'sequence_error' is the sequence error rate in a pass. """ @@ -257,7 +255,6 @@ class EditDistance(Evaluator): compare_result_int = layers.cast(x=compare_result, dtype='int') seq_right_count = layers.reduce_sum(compare_result_int) seq_error_count = layers.elementwise_sub(x=seq_num, y=seq_right_count) - #error = layers.cast(x=error, dtype='float32') total_distance = layers.reduce_sum(distances) layers.sums( input=[self.total_distance, total_distance], diff --git a/python/paddle/v2/fluid/layers/nn.py b/python/paddle/v2/fluid/layers/nn.py index 99168ecc228045a0206aff1b7de5fc17c1438fe2..db6ce09713c3360eb2759363692adebcb5ac9d87 100644 --- a/python/paddle/v2/fluid/layers/nn.py +++ b/python/paddle/v2/fluid/layers/nn.py @@ -2392,10 +2392,7 @@ def matmul(x, y, transpose_x=False, transpose_y=False, name=None): return out -def edit_distance(input, - label, - normalized=False, - ignored_tokens=None, +def edit_distance(input, label, normalized=True, ignored_tokens=None, name=None): """ EditDistance operator computes the edit distances between a batch of