From 26235c2770f10fc6975a06fd3a8167cbd23029a9 Mon Sep 17 00:00:00 2001 From: Chris Dyer Date: Mon, 25 Nov 2013 00:14:16 -0500 Subject: remove dead code, add adagrad crf learner --- utils/weights.cc | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'utils/weights.cc') diff --git a/utils/weights.cc b/utils/weights.cc index effdfc5e..1f66c441 100644 --- a/utils/weights.cc +++ b/utils/weights.cc @@ -127,9 +127,11 @@ void Weights::InitSparseVector(const vector& dv, } void Weights::SanityCheck(const vector& w) { - for (unsigned i = 0; i < w.size(); ++i) { - assert(!std::isnan(w[i])); - assert(!std::isinf(w[i])); + for (unsigned i = 1; i < w.size(); ++i) { + if (std::isnan(w[i]) || std::isinf(w[i])) { + cerr << FD::Convert(i) << " has bad weight: " << w[i] << endl; + abort(); + } } } @@ -161,7 +163,7 @@ string Weights::GetString(const vector& w, bool hide_zero_value_features) { ostringstream os; os.precision(17); - int nf = FD::NumFeats(); + const unsigned nf = FD::NumFeats(); for (unsigned i = 1; i < nf; i++) { weight_t val = (i < w.size() ? w[i] : 0.0); if (hide_zero_value_features && val == 0.0) { -- cgit v1.2.3