summaryrefslogtreecommitdiff
path: root/decoder
diff options
context:
space:
mode:
authorChris Dyer <cdyer@cs.cmu.edu>2011-03-22 11:35:45 -0400
committerChris Dyer <cdyer@cs.cmu.edu>2011-03-22 11:35:45 -0400
commit4bc9ea17ba9f85c899e35a9d657ee3f174ff2863 (patch)
tree202830ffde07b6db74e6454bbfefca8253dcdc6b /decoder
parentda6c892bc05a5520910e23089d83ceb1f2a0fbb4 (diff)
check for infs
Diffstat (limited to 'decoder')
-rw-r--r--decoder/decoder.cc8
1 files changed, 6 insertions, 2 deletions
diff --git a/decoder/decoder.cc b/decoder/decoder.cc
index 8a03c5c9..a16a9b5a 100644
--- a/decoder/decoder.cc
+++ b/decoder/decoder.cc
@@ -810,8 +810,12 @@ bool DecoderImpl::Decode(const string& input, DecoderObserver* o) {
const prob_t z = forest.ComputeEdgePosteriors(1.0, &posteriors);
if (!SILENT) { cerr << " " << passtr << " adding summary feature " << FD::Convert(rp.fid_summary) << " log(Z)=" << log(z) << endl; }
assert(forest.edges_.size() == posteriors.size());
- for (int i = 0; i < posteriors.size(); ++i)
- forest.edges_[i].feature_values_.set_value(rp.fid_summary, log(posteriors[i] / z));
+ if (!isfinite(log(z)) || isnan(log(z))) {
+ cerr << " " << passtr << " !!! Invalid partition detected, abandoning.\n";
+ } else {
+ for (int i = 0; i < posteriors.size(); ++i)
+ forest.edges_[i].feature_values_.set_value(rp.fid_summary, log(posteriors[i] / z));
+ }
}
string fullbp = "beam_prune" + StringSuffixForRescoringPass(pass);