From 1b0d40959f529b67db3b9d10dbf93101e0c65c7c Mon Sep 17 00:00:00 2001 From: Patrick Simianer Date: Mon, 27 Jan 2014 10:40:14 +0100 Subject: verbose parameter for mira (thanks Felix!) --- training/mira/kbest_cut_mira.cc | 9 ++++++--- training/mira/mira.py | 4 ++++ 2 files changed, 10 insertions(+), 3 deletions(-) (limited to 'training/mira') diff --git a/training/mira/kbest_cut_mira.cc b/training/mira/kbest_cut_mira.cc index 990609d7..9415909e 100644 --- a/training/mira/kbest_cut_mira.cc +++ b/training/mira/kbest_cut_mira.cc @@ -95,7 +95,8 @@ bool InitCommandLine(int argc, char** argv, po::variables_map* conf) { ("stream,t", "Stream mode (used for realtime)") ("weights_output,O",po::value(),"Directory to write weights to") ("output_dir,D",po::value(),"Directory to place output in") - ("decoder_config,c",po::value(),"Decoder configuration file"); + ("decoder_config,c",po::value(),"Decoder configuration file") + ("verbose,v",po::value()->zero_tokens(),"verbose stderr output"); po::options_description clo("Command line options"); clo.add_options() ("config", po::value(), "Configuration file") @@ -627,6 +628,7 @@ int main(int argc, char** argv) { vector corpus; + const bool VERBOSE = conf.count("verbose"); const string metric_name = conf["mt_metric"].as(); optimizer = conf["optimizer"].as(); fear_select = conf["fear"].as(); @@ -790,7 +792,8 @@ int main(int argc, char** argv) { double margin = cur_bad.features.dot(dense_weights) - cur_good.features.dot(dense_weights); double mt_loss = (cur_good.mt_metric - cur_bad.mt_metric); const double loss = margin + mt_loss; - cerr << "LOSS: " << loss << " Margin:" << margin << " BLEUL:" << mt_loss << " " << cur_bad.features.dot(dense_weights) << " " << cur_good.features.dot(dense_weights) < 0.0 || !checkloss) { SparseVector diff = cur_good.features; diff -= cur_bad.features; @@ -928,7 +931,7 @@ int main(int argc, char** argv) { lambdas += (cur_pair[1]->features) * step_size; lambdas -= (cur_pair[0]->features) * step_size; - cerr << " Lambdas " << lambdas << endl; + if (VERBOSE) cerr << " Lambdas " << lambdas << endl; //reload weights based on update dense_weights.clear(); diff --git a/training/mira/mira.py b/training/mira/mira.py index d5a1d9f8..1555cbb4 100755 --- a/training/mira/mira.py +++ b/training/mira/mira.py @@ -143,6 +143,8 @@ def main(): parser.add_argument('--pass-suffix', help='multipass decoding iteration. see documentation ' 'at www.cdec-decoder.org for more information') + parser.add_argument('-v', '--verbose', + help='more verbose mira optimizers') args = parser.parse_args() args.metric = args.metric.upper() @@ -352,6 +354,8 @@ def optimize(args, script_dir, dev_size): decoder_cmd += ' -a' if not args.no_pseudo: decoder_cmd += ' -e' + if args.verbose: + decoder_cmd += ' -v' #always use fork parallel_cmd = '{0} --use-fork -e {1} -j {2} --'.format( -- cgit v1.2.3 From 7201ef7d46e39f42923d89688a1cb82c757abe61 Mon Sep 17 00:00:00 2001 From: Patrick Simianer Date: Tue, 22 Jul 2014 11:40:59 +0200 Subject: mira qsub --- training/mira/mira.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'training/mira') diff --git a/training/mira/mira.py b/training/mira/mira.py index 691a62a6..ec9c2d64 100755 --- a/training/mira/mira.py +++ b/training/mira/mira.py @@ -143,6 +143,10 @@ def main(): parser.add_argument('--pass-suffix', help='multipass decoding iteration. see documentation ' 'at www.cdec-decoder.org for more information') + parser.add_argument('--qsub', + help='use qsub', action='store_true') + parser.add_argument('--pmem', + help='memory for qsub', type=str, default='5G') parser.add_argument('-v', '--verbose', help='more verbose mira optimizers') args = parser.parse_args() @@ -317,6 +321,8 @@ def split_devset(dev, outdir): def optimize(args, script_dir, dev_size): parallelize = script_dir+'/../utils/parallelize.pl' + if args.qsub: + parallelize += " -p %s"%args.pmem decoder = script_dir+'/kbest_cut_mira' (source, refs) = split_devset(args.devset, args.output_dir) port = random.randint(15000,50000) @@ -358,9 +364,12 @@ def optimize(args, script_dir, dev_size): if args.verbose: decoder_cmd += ' -v' - #always use fork - parallel_cmd = '{0} --use-fork -e {1} -j {2} --'.format( - parallelize, logdir, args.jobs) + if args.qsub: + parallel_cmd = '{0} -e {1} -j {2} --'.format( + parallelize, logdir, args.jobs) + else: + parallel_cmd = '{0} --use-fork -e {1} -j {2} --'.format( + parallelize, logdir, args.jobs) cmd = parallel_cmd + ' ' + decoder_cmd logging.info('OPTIMIZATION COMMAND: {}'.format(cmd)) -- cgit v1.2.3