clean code in tuning script

pull/2/head
Yibing Liu 7 years ago
parent e6e7b13222
commit 764ce62445

@ -140,13 +140,11 @@ def tune():
for target, result in zip(target_transcripts, result_transcripts): for target, result in zip(target_transcripts, result_transcripts):
err_sum[index] += error_rate_func(target, result) err_sum[index] += error_rate_func(target, result)
err_ave[index] = err_sum[index] / num_ins err_ave[index] = err_sum[index] / num_ins
# print("alpha = %f, beta = %f, WER = %f" %
# (alpha, beta, err_ave[index]))
if index % 2 == 0: if index % 2 == 0:
sys.stdout.write('.') sys.stdout.write('.')
sys.stdout.flush() sys.stdout.flush()
# output on-line tuning result at the the end of current batch # output on-line tuning result at the end of current batch
err_ave_min = min(err_ave) err_ave_min = min(err_ave)
min_index = err_ave.index(err_ave_min) min_index = err_ave.index(err_ave_min)
print("\nBatch %d [%d/?], current opt (alpha, beta) = (%s, %s), " print("\nBatch %d [%d/?], current opt (alpha, beta) = (%s, %s), "
@ -156,7 +154,7 @@ def tune():
args.error_rate_type, err_ave_min)) args.error_rate_type, err_ave_min))
cur_batch += 1 cur_batch += 1
# output WER/CER at every point # output WER/CER at every (alpha, beta)
print("\nFinal %s:\n" % args.error_rate_type) print("\nFinal %s:\n" % args.error_rate_type)
for index in xrange(len(params_grid)): for index in xrange(len(params_grid)):
print("(alpha, beta) = (%s, %s), [%s] = %f" print("(alpha, beta) = (%s, %s), [%s] = %f"

Loading…
Cancel
Save