summaryrefslogtreecommitdiff
path: root/decoder/viterbi.cc
diff options
context:
space:
mode:
authorgraehl <graehl@ec762483-ff6d-05da-a07a-a48fb63a330f>2010-07-08 19:30:57 +0000
committergraehl <graehl@ec762483-ff6d-05da-a07a-a48fb63a330f>2010-07-08 19:30:57 +0000
commit0025cd84f93ed8e01a9b7fd4f2ce45d80ba2bf5a (patch)
tree73440ae9d850b1d0444e11c353aa82f5a9e4e96f /decoder/viterbi.cc
parentb8cd8c32c7a89f99f3d8b8813d11517e89ecf022 (diff)
warning only on feat dotprod vs. viterbi prob mismatch
git-svn-id: https://ws10smt.googlecode.com/svn/trunk@187 ec762483-ff6d-05da-a07a-a48fb63a330f
Diffstat (limited to 'decoder/viterbi.cc')
-rw-r--r--decoder/viterbi.cc11
1 files changed, 8 insertions, 3 deletions
diff --git a/decoder/viterbi.cc b/decoder/viterbi.cc
index 6a7a970b..ea0cd95e 100644
--- a/decoder/viterbi.cc
+++ b/decoder/viterbi.cc
@@ -116,15 +116,20 @@ inline bool close_enough(double a,double b,double epsilon)
return diff<=epsilon*fabs(a) || diff<=epsilon*fabs(b);
}
-FeatureVector ViterbiFeatures(Hypergraph const& hg,FeatureWeights const* weights) {
+FeatureVector ViterbiFeatures(Hypergraph const& hg,FeatureWeights const* weights,bool fatal_dotprod_disagreement) {
FeatureVector r;
const prob_t p = Viterbi<FeatureVectorTraversal>(hg, &r);
if (weights) {
double logp=log(p);
double fv=r.dot(*weights);
const double EPSILON=1e-5;
- if (!close_enough(logp,fv,EPSILON))
- throw std::runtime_error("ViterbiFeatures log prob disagrees with features.dot(weights)"+boost::lexical_cast<string>(logp)+"!="+boost::lexical_cast<string>(fv));
+ if (!close_enough(logp,fv,EPSILON)) {
+ complaint="ViterbiFeatures log prob disagrees with features.dot(weights)"+boost::lexical_cast<string>(logp)+"!="+boost::lexical_cast<string>(fv);
+ if (fatal_dotprod_disagreement)
+ throw std::runtime_error(complaint);
+ else
+ cerr<<complaint<<endl;
+
}
return r;
}