diff options
author | Chris Dyer <prguest11@taipan.cs> | 2012-03-07 20:13:58 +0000 |
---|---|---|
committer | Chris Dyer <prguest11@taipan.cs> | 2012-03-07 20:13:58 +0000 |
commit | fdeb2267eb843ef80b5f2b95234a72c9c3333bbe (patch) | |
tree | 2026ed865bbb363523e63bfa7fc64e41f39c8e0a /training | |
parent | 63ea78b71bf913be248b064219734cac5ce41be2 (diff) |
more mpi fixes
Diffstat (limited to 'training')
-rw-r--r-- | training/mpi_flex_optimize.cc | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/training/mpi_flex_optimize.cc b/training/mpi_flex_optimize.cc index d98ea4dc..a9197208 100644 --- a/training/mpi_flex_optimize.cc +++ b/training/mpi_flex_optimize.cc @@ -272,6 +272,7 @@ int main(int argc, char** argv) { int iter = -1; bool converged = false; + vector<double> gg; while (!converged) { #ifdef HAVE_MPI mpi::timer timer; @@ -354,13 +355,14 @@ int main(int argc, char** argv) { // g /= (size_per_proc * size); if (!o) o.reset(new LBFGSOptimizer(FD::NumFeats(), lbfgs_memory_buffers)); - vector<double> gg(FD::NumFeats()); + gg.clear(); + gg.resize(FD::NumFeats()); if (gg.size() != cur_weights.size()) { cur_weights.resize(gg.size()); } for (SparseVector<double>::const_iterator it = g.begin(); it != g.end(); ++it) if (it->first) { gg[it->first] = it->second; } g.clear(); double r = ApplyRegularizationTerms(regularization_strength, - time_series_strength * (iter == 0 ? 0.0 : 1.0), + time_series_strength, // * (iter == 0 ? 0.0 : 1.0), cur_weights, prev_weights, &gg); @@ -375,10 +377,9 @@ int main(int argc, char** argv) { o->Optimize(obj, gg, &cur_weights); } #ifdef HAVE_MPI - // broadcast(world, x, 0); + broadcast(world, cur_weights, 0); broadcast(world, converged, 0); world.barrier(); - if (rank == 0) { cerr << " ELAPSED TIME THIS ITERATION=" << timer.elapsed() << endl; } #endif } prev_weights = cur_weights; |