From a6f3fb188e539eb1eb4d9e0be9fffdf15bdf9170 Mon Sep 17 00:00:00 2001 From: Patrick Simianer Date: Fri, 11 Nov 2011 12:42:24 +0100 Subject: more reporting, size_nonz() for fast sparse vector --- dtrain/dtrain.cc | 13 ++++++++++--- utils/fast_sparse_vector.h | 8 ++++++++ 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/dtrain/dtrain.cc b/dtrain/dtrain.cc index 2d15f059..5c95c7f1 100644 --- a/dtrain/dtrain.cc +++ b/dtrain/dtrain.cc @@ -387,7 +387,10 @@ main(int argc, char** argv) ++ii; - if (hstreaming) rep.update_counter("Seen", 1u); + if (hstreaming) { + rep.update_counter("Seen #"+boost::lexical_cast(t+1), 1u); + rep.update_counter("Seen", 1u); + } } // input loop @@ -398,6 +401,7 @@ main(int argc, char** argv) if (hstreaming) { rep.update_counter("|Input|", ii+1); rep.update_gcounter("|Input|", ii+1); + rep.update_gcounter("Shards", 1u); } } @@ -438,10 +442,13 @@ main(int argc, char** argv) } if (hstreaming) { - rep.update_counter("Score avg #"+boost::lexical_cast(t+1), score_avg); - rep.update_counter("Model avg #"+boost::lexical_cast(t+1), model_avg); + rep.update_counter("Score 1best avg #"+boost::lexical_cast(t+1), score_avg); + rep.update_counter("Model 1best avg #"+boost::lexical_cast(t+1), model_avg); rep.update_counter("Pairs avg #"+boost::lexical_cast(t+1), npairs/(weight_t)in_sz); rep.update_counter("Updates avg #"+boost::lexical_cast(t+1), nup/(weight_t)in_sz); + unsigned nonz = (unsigned)lambdas.size_nonzero(); + rep.update_counter("Non zero feature count #"+boost::lexical_cast(t+1), nonz); + rep.update_gcounter("Non zero feature count #"+boost::lexical_cast(t+1), nonz); } pair remember; diff --git a/utils/fast_sparse_vector.h b/utils/fast_sparse_vector.h index 8daaac85..8fe6cb3d 100644 --- a/utils/fast_sparse_vector.h +++ b/utils/fast_sparse_vector.h @@ -190,6 +190,14 @@ class FastSparseVector { else return local_size_; } + size_t size_nonzero() const { + size_t sz = 0; + const_iterator it = this->begin(); + for (; it != this->end(); ++it) { + if (nonzero(it->first)) sz++; + } + return sz; + } inline void clear() { if (is_remote_) delete data_.rbmap; is_remote_ = false; -- cgit v1.2.3