From 1aac806af7785ab440d300ca5cfa8833e3ed61d3 Mon Sep 17 00:00:00 2001 From: Chris Dyer Date: Fri, 18 Dec 2009 01:27:19 -0500 Subject: add support for freezing the feature set to a user-specified list, even if feature detectors create additional features --- decoder/cdec.cc | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) (limited to 'decoder/cdec.cc') diff --git a/decoder/cdec.cc b/decoder/cdec.cc index c6773cce..c6a0057f 100644 --- a/decoder/cdec.cc +++ b/decoder/cdec.cc @@ -53,6 +53,7 @@ void InitCommandLine(int argc, char** argv, po::variables_map* conf) { ("input,i",po::value()->default_value("-"),"Source file") ("grammar,g",po::value >()->composing(),"Either SCFG grammar file(s) or phrase tables file(s)") ("weights,w",po::value(),"Feature weights file") + ("no_freeze_feature_set,Z", "Do not freeze feature set after reading feature weights file") ("feature_function,F",po::value >()->composing(), "Additional feature function(s) (-L for list)") ("list_feature_functions,L","List available feature functions") ("add_pass_through_rules,P","Add rules to translate OOV words as themselves") @@ -248,6 +249,20 @@ int main(int argc, char** argv) { exit(1); } + // load feature weights (and possibly freeze feature set) + vector feature_weights; + Weights w; + if (conf.count("weights")) { + w.InitFromFile(conf["weights"].as()); + feature_weights.resize(FD::NumFeats()); + w.InitVector(&feature_weights); + if (!conf.count("no_freeze_feature_set")) { + cerr << "Freezing feature set (use --no_freeze_feature_set to change)." << endl; + FD::Freeze(); + } + } + + // set up translation back end if (formalism == "scfg") translator.reset(new SCFGTranslator(conf)); else if (formalism == "fst") @@ -263,14 +278,6 @@ int main(int argc, char** argv) { else assert(!"error"); - vector feature_weights; - Weights w; - if (conf.count("weights")) { - w.InitFromFile(conf["weights"].as()); - feature_weights.resize(FD::NumFeats()); - w.InitVector(&feature_weights); - } - // set up additional scoring features vector > pffs; vector late_ffs; @@ -480,6 +487,7 @@ int main(int argc, char** argv) { } if (output_training_vector) { + acc_vec.clear_value(0); ++g_count; if (g_count % combine_size == 0) { if (encode_b64) { -- cgit v1.2.3