diff options
author | Michael Denkowski <mdenkows@cs.cmu.edu> | 2013-09-17 22:05:32 -0700 |
---|---|---|
committer | Michael Denkowski <mdenkows@cs.cmu.edu> | 2013-09-17 22:05:32 -0700 |
commit | f96397d3a34fd5279c92a21f66cfa7538f60cb52 (patch) | |
tree | 0e656ef19ae8f1fb6402adc44000b3aa704eb387 /utils | |
parent | 769dfa1e69c22d4aea37840a955db7fd2cf3a4d7 (diff) |
Save/load state in realtime
Diffstat (limited to 'utils')
-rw-r--r-- | utils/weights.cc | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/utils/weights.cc b/utils/weights.cc index 1284f686..effdfc5e 100644 --- a/utils/weights.cc +++ b/utils/weights.cc @@ -163,15 +163,13 @@ string Weights::GetString(const vector<weight_t>& w, os.precision(17); int nf = FD::NumFeats(); for (unsigned i = 1; i < nf; i++) { - if (hide_zero_value_features && w[i] == 0.0) { + weight_t val = (i < w.size() ? w[i] : 0.0); + if (hide_zero_value_features && val == 0.0) { continue; } - os << FD::Convert(i) << '=' << w[i]; - if (i < nf - 1) { - os << ' '; - } + os << ' ' << FD::Convert(i) << '=' << val; } - return os.str(); + return os.str().substr(1); } void Weights::UpdateFromString(string& w_string, |