diff options
author | Paul Baltescu <pauldb89@gmail.com> | 2013-11-25 23:24:42 +0000 |
---|---|---|
committer | Paul Baltescu <pauldb89@gmail.com> | 2013-11-25 23:24:42 +0000 |
commit | 2b95390f08d9f556e6207ecff03b4b0fd5ede993 (patch) | |
tree | 7a96e837a3e28cfc8258a3c5293ac333d7c3e29e /utils/weights.cc | |
parent | 467ef6ce78cfe7341a696ebf0948e377be619ae5 (diff) | |
parent | 62a2526e69eb1570bf349763fc8bb65179337918 (diff) |
Merge branch 'master' of https://github.com/redpony/cdec
Diffstat (limited to 'utils/weights.cc')
-rw-r--r-- | utils/weights.cc | 10 |
1 files changed, 6 insertions, 4 deletions
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<weight_t>& dv, } void Weights::SanityCheck(const vector<weight_t>& 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<weight_t>& 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) { |