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
commit3e6605c395fa9798f4bd0b7ce2227cd5a5391a25 (patch)
treed013a7c1d6c1ca03e0794fe0617f3a5f90de3c81 /decoder
parent2b9cfc501f3d753c267a8273038cc36f40b488aa (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);