From e716e3f01a7787ff20f185d6fa1882ed8de941fb Mon Sep 17 00:00:00 2001 From: Patrick Simianer Date: Fri, 30 Jan 2015 10:43:48 +0100 Subject: dtrain: output ranking to folder --- training/dtrain/dtrain.cc | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'training/dtrain') diff --git a/training/dtrain/dtrain.cc b/training/dtrain/dtrain.cc index 0b648d95..b180bc82 100644 --- a/training/dtrain/dtrain.cc +++ b/training/dtrain/dtrain.cc @@ -43,7 +43,7 @@ dtrain_init(int argc, char** argv, po::variables_map* cfg) ("batch", po::value()->zero_tokens(), "do batch optimization") ("repeat", po::value()->default_value(1), "repeat optimization over kbest list this number of times") ("check", po::value()->zero_tokens(), "produce list of loss differentials") - ("print_ranking", po::value()->zero_tokens(), "output kbest with model score and metric") + ("output_ranking", po::value()->default_value(""), "Output kbests with model scores and metric per iteration to this folder.") ("noup", po::value()->zero_tokens(), "do not update weights"); po::options_description cl("Command Line Options"); cl.add_options() @@ -115,8 +115,6 @@ main(int argc, char** argv) if (cfg.count("rescale")) rescale = true; bool keep = false; if (cfg.count("keep")) keep = true; - bool print_ranking = false; - if (cfg.count("print_ranking")) print_ranking = true; const unsigned k = cfg["k"].as(); const unsigned N = cfg["N"].as(); @@ -127,6 +125,7 @@ main(int argc, char** argv) const string pair_sampling = cfg["pair_sampling"].as(); const score_t pair_threshold = cfg["pair_threshold"].as(); const string select_weights = cfg["select_weights"].as(); + const string output_ranking = cfg["output_ranking"].as(); const float hi_lo = cfg["hi_lo"].as(); const score_t approx_bleu_d = cfg["approx_bleu_d"].as(); const unsigned max_pairs = cfg["max_pairs"].as(); @@ -359,12 +358,15 @@ main(int argc, char** argv) // get (scored) samples vector* samples = observer->GetSamples(); - if (print_ranking) { + if (output_ranking != "") { + WriteFile of(output_ranking+"/"+to_string(t)+"."+to_string(ii)+".list"); // works with '-' + stringstream ss; for (auto s: *samples) { - cout << ii << " ||| "; - printWordIDVec(s.w, cout); - cout << " ||| " << s.model << " ||| " << s.score << endl; + ss << ii << " ||| "; + printWordIDVec(s.w, ss); + ss << " ||| " << s.model << " ||| " << s.score << endl; } + of.get() << ss.str(); } if (verbose) { @@ -569,8 +571,6 @@ main(int argc, char** argv) if (t == 0) in_sz = ii; // remember size of input (# lines) - if (print_ranking) cout << "---" << endl; - if (batch) { lambdas.plus_eq_v_times_s(batch_updates, eta); if (gamma) lambdas.plus_eq_v_times_s(lambdas, -2*gamma*eta*(1./npairs)); -- cgit v1.2.3