From 96379c9adef0a1c5b970e7765369e85833514405 Mon Sep 17 00:00:00 2001 From: Patrick Simianer Date: Fri, 26 Jun 2015 15:24:42 +0200 Subject: refactoring, more features (resetting, setting learning rate(s)) --- training/dtrain/dtrain_net_interface.h | 36 ++++++++++++++++++++++++++-------- 1 file changed, 28 insertions(+), 8 deletions(-) (limited to 'training/dtrain/dtrain_net_interface.h') diff --git a/training/dtrain/dtrain_net_interface.h b/training/dtrain/dtrain_net_interface.h index 2c539930..e603a87f 100644 --- a/training/dtrain/dtrain_net_interface.h +++ b/training/dtrain/dtrain_net_interface.h @@ -6,6 +6,23 @@ namespace dtrain { +inline void +weightsToJson(SparseVector& w, ostringstream& os) +{ + vector strs; + for (typename SparseVector::iterator it=w.begin(),e=w.end(); it!=e; ++it) { + ostringstream a; + a << "\"" << FD::Convert(it->first) << "\":" << it->second; + strs.push_back(a.str()); + } + for (vector::const_iterator it=strs.begin(); it!=strs.end(); it++) { + os << *it; + if ((it+1) != strs.end()) + os << ","; + os << endl; + } +} + template inline void vectorAsString(SparseVector& v, ostringstream& os) @@ -39,14 +56,17 @@ dtrain_net_init(int argc, char** argv, po::variables_map* conf) { po::options_description ini("Configuration File Options"); ini.add_options() - ("decoder_conf,C", po::value(), "configuration file for decoder") - ("k", po::value()->default_value(100), "size of kbest list") - ("N", po::value()->default_value(4), "N for BLEU approximation") - ("margin,m", po::value()->default_value(0.), "margin for margin perceptron") - ("output,o", po::value()->default_value(""), "final weights file") - ("input_weights,w", po::value(), "input weights file") - ("learning_rate,l", po::value()->default_value(1.0), "learning rate") - ("debug_output,d", po::value()->default_value(""), "file for debug output"); + ("decoder_conf,C", po::value(), "configuration file for decoder") + ("k", po::value()->default_value(100), "size of kbest list") + ("N", po::value()->default_value(4), "N for BLEU approximation") + ("margin,m", po::value()->default_value(0.), "margin for margin perceptron") + ("output,o", po::value()->default_value(""), "final weights file") + ("input_weights,w", po::value(), "input weights file") + ("learning_rate,l", po::value()->default_value(1.0), "learning rate") + ("learning_rate_sparse,l", po::value()->default_value(1.0), "learning rate for sparse features") + ("dense_features,D", po::value()->default_value("EgivenFCoherent SampleCountF CountEF MaxLexFgivenE MaxLexEgivenF IsSingletonF IsSingletonFE Glue WordPenalty PassThrough LanguageModel LanguageModel_OOV"), + "dense features") + ("debug_output,d", po::value()->default_value(""), "file for debug output"); po::options_description cl("Command Line Options"); cl.add_options() ("conf,c", po::value(), "dtrain configuration file") -- cgit v1.2.3