fix division by zero in normalized edit distance
This commit is contained in:
parent
f0b17556b8
commit
3953e51381
3
test.py
3
test.py
|
@ -126,6 +126,9 @@ def validation(model, criterion, evaluation_loader, converter, opt):
|
||||||
|
|
||||||
if pred == gt:
|
if pred == gt:
|
||||||
n_correct += 1
|
n_correct += 1
|
||||||
|
if len(gt) == 0:
|
||||||
|
norm_ED += 1
|
||||||
|
else:
|
||||||
norm_ED += edit_distance(pred, gt) / len(gt)
|
norm_ED += edit_distance(pred, gt) / len(gt)
|
||||||
|
|
||||||
accuracy = n_correct / float(length_of_data) * 100
|
accuracy = n_correct / float(length_of_data) * 100
|
||||||
|
|
Loading…
Reference in New Issue