summaryrefslogtreecommitdiff
path: root/training/mira
diff options
context:
space:
mode:
authorPatrick Simianer <p@simianer.de>2014-01-27 10:40:14 +0100
committerPatrick Simianer <p@simianer.de>2014-01-27 10:40:14 +0100
commit85088dc6e09d4e91038aea46e8d20b5c34053b5f (patch)
tree33c4e4c5b7f2cea67b8ca9c86f3cc29468d6eab3 /training/mira
parent64e135092c140310345bb7fcf3dffc8072e652d3 (diff)
verbose parameter for mira (thanks Felix!)
Diffstat (limited to 'training/mira')
-rw-r--r--training/mira/kbest_cut_mira.cc9
-rwxr-xr-xtraining/mira/mira.py4
2 files changed, 10 insertions, 3 deletions
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<string>(),"Directory to write weights to")
("output_dir,D",po::value<string>(),"Directory to place output in")
- ("decoder_config,c",po::value<string>(),"Decoder configuration file");
+ ("decoder_config,c",po::value<string>(),"Decoder configuration file")
+ ("verbose,v",po::value<bool>()->zero_tokens(),"verbose stderr output");
po::options_description clo("Command line options");
clo.add_options()
("config", po::value<string>(), "Configuration file")
@@ -627,6 +628,7 @@ int main(int argc, char** argv) {
vector<string> corpus;
+ const bool VERBOSE = conf.count("verbose");
const string metric_name = conf["mt_metric"].as<string>();
optimizer = conf["optimizer"].as<int>();
fear_select = conf["fear"].as<int>();
@@ -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) <<endl;
+ cerr << "LOSS: " << loss << " Margin:" << margin << " BLEUL:" << mt_loss << endl;
+ if (VERBOSE) cerr << cur_bad.features.dot(dense_weights) << " " << cur_good.features.dot(dense_weights) << endl;
if (loss > 0.0 || !checkloss) {
SparseVector<double> 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(