From 0025cd84f93ed8e01a9b7fd4f2ce45d80ba2bf5a Mon Sep 17 00:00:00 2001 From: graehl Date: Thu, 8 Jul 2010 19:30:57 +0000 Subject: warning only on feat dotprod vs. viterbi prob mismatch git-svn-id: https://ws10smt.googlecode.com/svn/trunk@187 ec762483-ff6d-05da-a07a-a48fb63a330f --- decoder/viterbi.cc | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'decoder/viterbi.cc') 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(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(logp)+"!="+boost::lexical_cast(fv)); + if (!close_enough(logp,fv,EPSILON)) { + complaint="ViterbiFeatures log prob disagrees with features.dot(weights)"+boost::lexical_cast(logp)+"!="+boost::lexical_cast(fv); + if (fatal_dotprod_disagreement) + throw std::runtime_error(complaint); + else + cerr<