提交 9ce8bcde 编写于 作者: W wanghaoshuang

Fix comments

上级 7ff3855d
...@@ -226,14 +226,12 @@ class EditDistance(Evaluator): ...@@ -226,14 +226,12 @@ class EditDistance(Evaluator):
for epoch in PASS_NUM: for epoch in PASS_NUM:
distance_evaluator.reset(exe) distance_evaluator.reset(exe)
for data in batches: for data in batches:
loss, sum_distance = exe.run(fetch_list=[cost] + distance_evaluator.metrics) loss = exe.run(fetch_list=[cost])
avg_distance = distance_evaluator.eval(exe) distance, sequence_error = distance_evaluator.eval(exe)
pass_distance = distance_evaluator.eval(exe)
In the above example: In the above example:
'sum_distance' is the sum of the batch's edit distance. 'distance' is the average of the edit distance rate in a pass.
'avg_distance' is the average of edit distance from the firt batch to the current batch. 'sequence_error' is the sequence error rate in a pass.
'pass_distance' is the average of edit distance from all the pass.
""" """
...@@ -257,7 +255,6 @@ class EditDistance(Evaluator): ...@@ -257,7 +255,6 @@ class EditDistance(Evaluator):
compare_result_int = layers.cast(x=compare_result, dtype='int') compare_result_int = layers.cast(x=compare_result, dtype='int')
seq_right_count = layers.reduce_sum(compare_result_int) seq_right_count = layers.reduce_sum(compare_result_int)
seq_error_count = layers.elementwise_sub(x=seq_num, y=seq_right_count) 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) total_distance = layers.reduce_sum(distances)
layers.sums( layers.sums(
input=[self.total_distance, total_distance], input=[self.total_distance, total_distance],
......
...@@ -2392,10 +2392,7 @@ def matmul(x, y, transpose_x=False, transpose_y=False, name=None): ...@@ -2392,10 +2392,7 @@ def matmul(x, y, transpose_x=False, transpose_y=False, name=None):
return out return out
def edit_distance(input, def edit_distance(input, label, normalized=True, ignored_tokens=None,
label,
normalized=False,
ignored_tokens=None,
name=None): name=None):
""" """
EditDistance operator computes the edit distances between a batch of EditDistance operator computes the edit distances between a batch of
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册