summaryrefslogtreecommitdiff
path: root/pro-train
diff options
context:
space:
mode:
authorChris Dyer <cdyer@cs.cmu.edu>2011-09-14 14:43:03 +0100
committerChris Dyer <cdyer@cs.cmu.edu>2011-09-14 14:43:03 +0100
commit1ef494a6ece4852d51a437c4f008500535343021 (patch)
tree6d358b210ab1519a1aec5ecfb67eb2e23f732b27 /pro-train
parent4c7d79b5aa38514444a45d54697ad93a6bbae539 (diff)
fix for potential segv with no weights
Diffstat (limited to 'pro-train')
-rw-r--r--pro-train/mr_pro_reduce.cc2
1 files changed, 1 insertions, 1 deletions
diff --git a/pro-train/mr_pro_reduce.cc b/pro-train/mr_pro_reduce.cc
index e71347ba..6b491918 100644
--- a/pro-train/mr_pro_reduce.cc
+++ b/pro-train/mr_pro_reduce.cc
@@ -100,7 +100,7 @@ double TrainingInference(const vector<weight_t>& x,
vector<weight_t>* g = NULL) {
double cll = 0;
for (int i = 0; i < corpus.size(); ++i) {
- const double dotprod = corpus[i].second.dot(x) + x[0]; // x[0] is bias
+ const double dotprod = corpus[i].second.dot(x) + (x.size() ? x[0] : weight_t()); // x[0] is bias
double lp_false = dotprod;
double lp_true = -dotprod;
if (0 < lp_true) {