Fix LogAdd (#316)

Using 0 as the initial value,  should not perform addition when both values are 0
This commit is contained in:
Peng He
2023-09-18 10:43:04 +08:00
committed by GitHub
parent c471423125
commit 5ca0ff8811

View File

@@ -18,10 +18,12 @@ void Hypotheses::Add(Hypothesis hyp) {
} else { } else {
it->second.log_prob = LogAdd<double>()(it->second.log_prob, hyp.log_prob); it->second.log_prob = LogAdd<double>()(it->second.log_prob, hyp.log_prob);
if (it->second.lm_log_prob != 0 && hyp.lm_log_prob != 0){
it->second.lm_log_prob = it->second.lm_log_prob =
LogAdd<double>()(it->second.lm_log_prob, hyp.lm_log_prob); LogAdd<double>()(it->second.lm_log_prob, hyp.lm_log_prob);
} }
} }
}
Hypothesis Hypotheses::GetMostProbable(bool length_norm) const { Hypothesis Hypotheses::GetMostProbable(bool length_norm) const {
if (length_norm == false) { if (length_norm == false) {