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
commit934ed3602c4226b667a2ff6b66228e897e814ccc (patch)
treecabef6dd002b9b887e2d93fe84b19a9592e7c0f3 /decoder/viterbi.cc
parent52a8d49e81c14b6f7ed3afb5bdb50b17391995a8 (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;
}