Add normalization to max-product, avoiding underflow.
parent
2856282932
commit
148d99f1d1
|
@ -121,6 +121,11 @@ namespace gtsam {
|
||||||
for (auto&& factor : factors) product = (*factor) * product;
|
for (auto&& factor : factors) product = (*factor) * product;
|
||||||
gttoc(product);
|
gttoc(product);
|
||||||
|
|
||||||
|
// Normalize the product factor to prevent underflow
|
||||||
|
Ordering ordering = Ordering::Colamd(DiscreteFactorGraph{product});
|
||||||
|
DecisionTreeFactor::shared_ptr normalization = product.sum(ordering);
|
||||||
|
product = product / (*normalization);
|
||||||
|
|
||||||
// max out frontals, this is the factor on the separator
|
// max out frontals, this is the factor on the separator
|
||||||
gttic(max);
|
gttic(max);
|
||||||
DecisionTreeFactor::shared_ptr max = product.max(frontalKeys);
|
DecisionTreeFactor::shared_ptr max = product.max(frontalKeys);
|
||||||
|
|
Loading…
Reference in New Issue