From 3953e51381679ce32faf54d0f05d74274d4143a7 Mon Sep 17 00:00:00 2001 From: Baek JeongHun Date: Mon, 1 Jul 2019 12:08:07 +0000 Subject: [PATCH] fix division by zero in normalized edit distance --- test.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/test.py b/test.py index 8c01134..7a35fd8 100755 --- a/test.py +++ b/test.py @@ -126,7 +126,10 @@ def validation(model, criterion, evaluation_loader, converter, opt): if pred == gt: n_correct += 1 - norm_ED += edit_distance(pred, gt) / len(gt) + if len(gt) == 0: + norm_ED += 1 + else: + norm_ED += edit_distance(pred, gt) / len(gt) accuracy = n_correct / float(length_of_data) * 100