diff options
author | Chris Dyer <cdyer@cs.cmu.edu> | 2011-04-22 13:38:32 -0400 |
---|---|---|
committer | Chris Dyer <cdyer@cs.cmu.edu> | 2011-04-22 13:38:32 -0400 |
commit | 9986bc8fe11435b2134350bba24aa0139d2665ac (patch) | |
tree | d27b526d929b788dcdc2b1ab949c608a4751edfe /training | |
parent | 5061409a26050b9a4724b50b30d66d3c3a583951 (diff) |
make compatible with FastSparseVector
Diffstat (limited to 'training')
-rw-r--r-- | training/lbfgs_test.cc | 2 | ||||
-rw-r--r-- | training/mr_em_adapted_reduce.cc | 8 | ||||
-rw-r--r-- | training/mr_em_map_adapter.cc | 4 |
3 files changed, 7 insertions, 7 deletions
diff --git a/training/lbfgs_test.cc b/training/lbfgs_test.cc index 4171c118..fc21e98d 100644 --- a/training/lbfgs_test.cc +++ b/training/lbfgs_test.cc @@ -95,7 +95,7 @@ void TestSparseVector() { assert(B64::Decode(&obj, &v, &data[0], data.size())); cerr << obj << "\t" << v << endl; assert(obj == iobj); - assert(g.num_active() == v.num_active()); + assert(g.size() == v.size()); } int main() { diff --git a/training/mr_em_adapted_reduce.cc b/training/mr_em_adapted_reduce.cc index 29416348..d4c16a2f 100644 --- a/training/mr_em_adapted_reduce.cc +++ b/training/mr_em_adapted_reduce.cc @@ -53,7 +53,7 @@ void Maximize(const bool use_vb, const SparseVector<double>& counts = *pc; if (use_vb) - assert(total_event_types >= counts.num_active()); + assert(total_event_types >= counts.size()); double tot = 0; for (SparseVector<double>::const_iterator it = counts.begin(); @@ -73,7 +73,7 @@ void Maximize(const bool use_vb, } } #if 0 - if (counts.num_active() < 50) { + if (counts.size() < 50) { for (SparseVector<double>::const_iterator it = counts.begin(); it != counts.end(); ++it) { cerr << " p(" << FD::Convert(it->first) << ")=" << exp(it->second); @@ -112,7 +112,7 @@ int main(int argc, char** argv) { if (cur_key.size() > 0) { // TODO shouldn't be num_active, should be total number // of events - Maximize(use_vb, alpha, acc.num_active(), &acc); + Maximize(use_vb, alpha, acc.size(), &acc); cout << cur_key << '\t'; if (use_b64) B64::Encode(0.0, acc, &cout); @@ -159,7 +159,7 @@ int main(int argc, char** argv) { } // TODO shouldn't be num_active, should be total number // of events - Maximize(use_vb, alpha, acc.num_active(), &acc); + Maximize(use_vb, alpha, acc.size(), &acc); cout << cur_key << '\t'; if (use_b64) B64::Encode(0.0, acc, &cout); diff --git a/training/mr_em_map_adapter.cc b/training/mr_em_map_adapter.cc index a98e1b77..ead4598d 100644 --- a/training/mr_em_map_adapter.cc +++ b/training/mr_em_map_adapter.cc @@ -132,9 +132,9 @@ int main(int argc, char** argv) { for (SparseVector<double>::const_iterator it = cg.begin(); it != cg.end(); ++it) { const int cond_var = event_mapper->Map(it->first); SparseVector<double>& cond_counts = counts[cond_var]; - int delta = cond_counts.num_active(); + int delta = cond_counts.size(); cond_counts.add_value(it->first, it->second); - delta = cond_counts.num_active() - delta; + delta = cond_counts.size() - delta; total += delta; } if (total > buffer_size) { |