fix division by zero in normalized edit distance

This commit is contained in:
Baek JeongHun 2019-07-01 12:08:07 +00:00
parent f0b17556b8
commit 3953e51381
1 changed files with 4 additions and 1 deletions

View File

@ -126,6 +126,9 @@ def validation(model, criterion, evaluation_loader, converter, opt):
if pred == gt:
n_correct += 1
if len(gt) == 0:
norm_ED += 1
else:
norm_ED += edit_distance(pred, gt) / len(gt)
accuracy = n_correct / float(length_of_data) * 100