summaryrefslogtreecommitdiff
path: root/utils/weights.cc
diff options
context:
space:
mode:
Diffstat (limited to 'utils/weights.cc')
-rw-r--r--utils/weights.cc7
1 files changed, 7 insertions, 0 deletions
diff --git a/utils/weights.cc b/utils/weights.cc
index ea8bd816..53089f89 100644
--- a/utils/weights.cc
+++ b/utils/weights.cc
@@ -81,3 +81,10 @@ void Weights::InitFromVector(const std::vector<double>& w) {
cerr << "WARNING: initializing weight vector has more features than the global feature dictionary!\n";
wv_.resize(FD::NumFeats(), 0);
}
+
+void Weights::InitFromVector(const SparseVector<double>& w) {
+ wv_.clear();
+ wv_.resize(FD::NumFeats(), 0.0);
+ for (int i = 1; i < FD::NumFeats(); ++i)
+ wv_[i] = w.value(i);
+}