From 217c4aaeba1c9f19b3420b526235bffd86c7a92b Mon Sep 17 00:00:00 2001 From: Chris Dyer Date: Mon, 23 Apr 2012 03:11:26 +0100 Subject: mst train --- rst_parser/mst_train.cc | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'rst_parser') diff --git a/rst_parser/mst_train.cc b/rst_parser/mst_train.cc index b3711aba..6332693e 100644 --- a/rst_parser/mst_train.cc +++ b/rst_parser/mst_train.cc @@ -28,6 +28,9 @@ void InitCommandLine(int argc, char** argv, po::variables_map* conf) { ("weights,w",po::value(), "Optional starting weights") ("output_every_i_iterations,I",po::value()->default_value(1), "Write weights every I iterations") ("regularization_strength,C",po::value()->default_value(1.0), "Regularization strength") +#ifdef HAVE_CMPH + ("cmph_perfect_feature_hash,h", po::value(), "Load perfect hash function for features") +#endif #if HAVE_THREAD ("threads,T",po::value()->default_value(1), "Number of threads") #endif @@ -119,11 +122,19 @@ int main(int argc, char** argv) { int size = 1; po::variables_map conf; InitCommandLine(argc, argv, &conf); + if (conf.count("cmph_perfect_feature_hash")) { + cerr << "Loading perfect hash function from " << conf["cmph_perfect_feature_hash"].as() << " ...\n"; + FD::EnableHash(conf["cmph_perfect_feature_hash"].as()); + cerr << " " << FD::NumFeats() << " features in map\n"; + } ArcFeatureFunctions ffs; vector corpus; TrainingInstance::ReadTrainingCorpus(conf["training_data"].as(), &corpus, rank, size); + vector weights; + Weights::InitFromFile(conf["weights"].as(), &weights); vector forests(corpus.size()); SparseVector empirical; + cerr << "Extracting features...\n"; bool flag = false; for (int i = 0; i < corpus.size(); ++i) { TrainingInstance& cur = corpus[i]; @@ -149,9 +160,7 @@ int main(int argc, char** argv) { } if (flag) cerr << endl; //cerr << "EMP: " << empirical << endl; //DE - vector weights(FD::NumFeats(), 0.0); - if (conf.count("weights")) - Weights::InitFromFile(conf["weights"].as(), &weights); + weights.resize(FD::NumFeats(), 0.0); vector g(FD::NumFeats(), 0.0); cerr << "features initialized\noptimizing...\n"; boost::shared_ptr o; -- cgit v1.2.3