Print best and worst results in a WER report.

This commit is contained in:
Daniel 2020-02-05 17:50:27 +01:00
parent 6f5af8ec2c
commit a2f05ccabe
2 changed files with 11 additions and 5 deletions

View File

@ -2,7 +2,6 @@
# -*- coding: utf-8 -*-
from __future__ import absolute_import, division, print_function
import itertools
import json
import sys
@ -135,13 +134,16 @@ def evaluate(test_csvs, create_model, try_loading):
wer, cer, samples = calculate_report(wav_filenames, ground_truths, predictions, losses)
mean_loss = np.mean(losses)
# Take only the first report_count items
report_samples = itertools.islice(samples, FLAGS.report_count)
# Take only the first and last report_count items
best_samples = samples[-FLAGS.report_count:]
worst_samples = samples[:FLAGS.report_count]
report_samples = best_samples
report_samples.extend(reversed(worst_samples))
print('Test on %s - WER: %f, CER: %f, loss: %f' %
(dataset, wer, cer, mean_loss))
print('-' * 80)
for sample in report_samples:
for i, sample in enumerate(report_samples):
print('WER: %f, CER: %f, loss: %f' %
(sample.wer, sample.cer, sample.loss))
print(' - wav: file://%s' % sample.wav_filename)
@ -149,6 +151,10 @@ def evaluate(test_csvs, create_model, try_loading):
print(' - res: "%s"' % sample.res)
print('-' * 80)
if (i == FLAGS.report_count - 1):
print('[...]')
print('-' * 80)
return samples
samples = []

View File

@ -118,7 +118,7 @@ def create_flags():
f.DEFINE_boolean('show_progressbar', True, 'Show progress for training, validation and testing processes. Log level should be > 0.')
f.DEFINE_boolean('log_placement', False, 'whether to log device placement of the operators to the console')
f.DEFINE_integer('report_count', 10, 'number of phrases with lowest WER(best matching) to print out during a WER report')
f.DEFINE_integer('report_count', 7, 'number of phrases with best WER and with worst WER to print out during a WER report')
f.DEFINE_string('summary_dir', '', 'target directory for TensorBoard summaries - defaults to directory "deepspeech/summaries" within user\'s data home specified by the XDG Base Directory Specification')