From 6409c2c91b7fd3d3b42c6bb0d3376b83eb4d5611 Mon Sep 17 00:00:00 2001 From: redpony Date: Wed, 22 Sep 2010 18:28:00 +0000 Subject: few fixes git-svn-id: https://ws10smt.googlecode.com/svn/trunk@655 ec762483-ff6d-05da-a07a-a48fb63a330f --- training/mpi_online_optimize.cc | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'training') diff --git a/training/mpi_online_optimize.cc b/training/mpi_online_optimize.cc index 95b462bb..62821aa3 100644 --- a/training/mpi_online_optimize.cc +++ b/training/mpi_online_optimize.cc @@ -85,7 +85,7 @@ void InitCommandLine(int argc, char** argv, po::variables_map* conf) { } po::notify(*conf); - if (conf->count("help") || !conf->count("input_weights") || !conf->count("training_data") || !conf->count("decoder_config")) { + if (conf->count("help") || !conf->count("training_data") || !conf->count("decoder_config")) { cerr << dcmdline_options << endl; MPI::Finalize(); exit(1); @@ -201,14 +201,14 @@ int main(int argc, char** argv) { cerr << "MPI: I am " << rank << '/' << size << endl; register_feature_functions(); MT19937* rng = NULL; - if (rank == 0) rng = new MT19937; po::variables_map conf; InitCommandLine(argc, argv, &conf); // load initial weights Weights weights; - weights.InitFromFile(conf["input_weights"].as()); + if (conf.count("input_weights")) + weights.InitFromFile(conf["input_weights"].as()); // freeze feature set const bool freeze_feature_set = conf.count("freeze_feature_set"); @@ -228,6 +228,7 @@ int main(int argc, char** argv) { std::tr1::shared_ptr o; std::tr1::shared_ptr lr; + vector order; if (rank == 0) { // TODO config lr.reset(new ExponentialDecayLearningRate(corpus.size(), conf["eta_0"].as())); @@ -239,12 +240,21 @@ int main(int argc, char** argv) { } else { assert(!"fail"); } + + // randomize corpus + rng = new MT19937; + order.resize(corpus.size()); + for (unsigned i = 0; i < order.size(); ++i) order[i]=i; + Shuffle(&order, rng); } double objective = 0; vector lambdas; weights.InitVector(&lambdas); bool converged = false; - + const unsigned size_per_proc = conf["minibatch_size_per_proc"].as(); + for (int i = 0; i < size_per_proc; ++i) + cerr << "i=" << i << ": " << order[i] << endl; + abort(); TrainingObserver observer; while (!converged) { observer.Reset(); -- cgit v1.2.3