summaryrefslogtreecommitdiff
path: root/utils/weights.cc
diff options
context:
space:
mode:
authorPatrick Simianer <simianer@cl.uni-heidelberg.de>2013-11-28 11:11:22 +0100
committerPatrick Simianer <simianer@cl.uni-heidelberg.de>2013-11-28 11:11:22 +0100
commita6b3d3417c6d8a63c36a0fdc9c7cf06f7b06df9f (patch)
treeb86142bbf686a69cc3c9913faee18e073b8eece0 /utils/weights.cc
parent0be26bb330f3a976243c9da1d6908d4aaf033ebe (diff)
parenta5b4f06838585874f200c94028cd4d41d54c4f76 (diff)
Merge branch 'master' of github.com:pks/cdec-dtrain
Diffstat (limited to 'utils/weights.cc')
-rw-r--r--utils/weights.cc10
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) {