summaryrefslogtreecommitdiff
path: root/utils
diff options
context:
space:
mode:
authorMichael Denkowski <mdenkows@cs.cmu.edu>2013-09-17 22:05:32 -0700
committerMichael Denkowski <mdenkows@cs.cmu.edu>2013-09-17 22:05:32 -0700
commit6d427339b45f8aa74410437f91b5a01afc824120 (patch)
treeeb8914fe5fbd3d148610836f4f58fd660027230b /utils
parenta30a2e59ff117ad6bae80ece2bf535767daf7db6 (diff)
Save/load state in realtime
Diffstat (limited to 'utils')
-rw-r--r--utils/weights.cc10
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,