summaryrefslogtreecommitdiff
path: root/decoder/hg.cc
diff options
context:
space:
mode:
authorgraehl <graehl@ec762483-ff6d-05da-a07a-a48fb63a330f>2010-07-16 01:56:29 +0000
committergraehl <graehl@ec762483-ff6d-05da-a07a-a48fb63a330f>2010-07-16 01:56:29 +0000
commitff323448416bbfa691a9697ddf3b30a0398fa08a (patch)
treeef5a4a0ad13e434a8f15398427bcceffa9e4b261 /decoder/hg.cc
parent82eb07c3f06c343860e94595f858e92d532cbcb3 (diff)
more scale-insensitive creep - will work even if LogVal is using float (1e-6 of log of cutoff)
git-svn-id: https://ws10smt.googlecode.com/svn/trunk@275 ec762483-ff6d-05da-a07a-a48fb63a330f
Diffstat (limited to 'decoder/hg.cc')
-rw-r--r--decoder/hg.cc14
1 files changed, 7 insertions, 7 deletions
diff --git a/decoder/hg.cc b/decoder/hg.cc
index 0a257092..f0d6b3d5 100644
--- a/decoder/hg.cc
+++ b/decoder/hg.cc
@@ -213,23 +213,23 @@ void Hypergraph::SetPromise(NodeProbs const& inside,NodeProbs const& outside,dou
+// drop edges w/ max marginal prob less than cutoff. this means that bigger cutoff is stricter.
void Hypergraph::MarginPrune(vector<prob_t> const& io,prob_t cutoff,vector<bool> const* preserve_mask,bool safe_inside,bool verbose)
{
assert(io.size()==edges_.size());
- const prob_t BARELY_SMALLER(1e-6,false); // nearly 1; 1-epsilon
- //TODO: //FIXME: if EPSILON is 0, then remnants (useless edges that don't connect to top? or top-connected but not bottom-up buildable referneced?) are left in the hypergraph output that cause mr_vest_map to segfault. adding EPSILON probably just covers up the symptom by making it far less frequent; I imagine any time threshold is set by DensityPrune, cutoff is exactly equal to the io of several nodes, but because of how it's computed, some round slightly down vs. slightly up. probably the flaw is in PruneEdges.
- int ne=NumberOfEdges();
- cutoff*=BARELY_SMALLER;
- prob_t creep=BARELY_SMALLER.root(-(ne+1)); // start more permissive, then become less generous. this is barely more than 1. we want to do this because it's a disaster if something lower in a derivation tree is deleted, but the higher thing remains (unless safe_inside)
- vector<bool> prune(ne);
+ //TODO: //FIXME: if EPSILON is 0, then remnants (useless edges that don't connect to top? or top-connected but not bottom-up buildable referenced?) are left in the hypergraph output that cause mr_vest_map to segfault. adding EPSILON probably just covers up the symptom by making it far less frequent; I imagine any time threshold is set by DensityPrune, cutoff is exactly equal to the io of several nodes, but because of how it's computed, some round slightly down vs. slightly up. probably the flaw is in PruneEdges.
+
+ const prob_t creep=abslog(cutoff).pow(1e-6); // some barely >1 (small positive log) ratio. linear in logspace of course // start more permissive, then become less generous. this is barely more than 1. we want to do this because it's a disaster if something lower in a derivation tree is deleted, but the higher thing remains (unless safe_inside)
+
+ vector<bool> prune(edges_.size());
if (verbose) {
if (preserve_mask) cerr << preserve_mask->size() << " " << prune.size() << endl;
cerr<<"Finishing prune for "<<prune.size()<<" edges; CUTOFF=" << cutoff << endl;
}
unsigned pc = 0;
for (int i = 0; i < io.size(); ++i) {
- cutoff*=creep;
+ cutoff*=creep; // start more permissive, then become less generous. this is barely more than 1. we want to do this because it's a disaster if something lower in a derivation tree is deleted, but the higher thing remains (unless safe_inside)
const bool prune_edge = (io[i] < cutoff);
if (prune_edge) {
++pc;