summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Dyer <cdyer@vivace.clab.cs.cmu.edu>2015-03-26 22:53:06 -0400
committerChris Dyer <cdyer@vivace.clab.cs.cmu.edu>2015-03-26 22:53:06 -0400
commit1543b24f05d344568560f4ff15905939d0281062 (patch)
treeb69b7ad6de05ff184abeed82c5b4a74f54fe8de5
parent0abf34b3bf216b041dab3c338f9ac263d912376c (diff)
fix bug
-rwxr-xr-xtraining/mira/mira.py9
1 files changed, 6 insertions, 3 deletions
diff --git a/training/mira/mira.py b/training/mira/mira.py
index ec9c2d64..dc1bd724 100755
--- a/training/mira/mira.py
+++ b/training/mira/mira.py
@@ -152,6 +152,9 @@ def main():
args = parser.parse_args()
args.metric = args.metric.upper()
+ score_sign = 1.0
+ if args.metric == 'TER' or args.metric == 'WER' or args.metric == 'CER':
+ score_sign = -1.0
if not args.update_size:
args.update_size = args.kbest_size
@@ -319,7 +322,7 @@ def split_devset(dev, outdir):
refs.close()
return (outdir+'/source.input', outdir+'/refs.input')
-def optimize(args, script_dir, dev_size):
+def optimize(args, script_dir, dev_size, score_sign):
parallelize = script_dir+'/../utils/parallelize.pl'
if args.qsub:
parallelize += " -p %s"%args.pmem
@@ -330,7 +333,7 @@ def optimize(args, script_dir, dev_size):
num_features = 0
last_p_score = 0
best_score_iter = -1
- best_score = -1
+ best_score = -10 * score_sign
i = 0
hope_best_fear = {'hope':[],'best':[],'fear':[]}
#main optimization loop
@@ -450,7 +453,7 @@ def optimize(args, script_dir, dev_size):
hope_best_fear['fear'].append(dec_score_f)
logging.info('DECODER SCORE: {0} HOPE: {1} FEAR: {2}'.format(
dec_score, dec_score_h, dec_score_f))
- if dec_score > best_score:
+ if score_sign*dec_score > score_sign*best_score:
best_score_iter = i
best_score = dec_score