MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / LogSumExp

Function LogSumExp

tensorflow/core/util/ctc/ctc_loss_util.h:36–49  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

34// (GravesTh) Eq. 7.18
35template <typename T>
36inline T LogSumExp(T log_prob_1, T log_prob_2) {
37 // const T kLogZero = -std::numeric_limits<T>::infinity();
38 // Always have 'b' be the smaller number to avoid the exponential from
39 // blowing up.
40 if (log_prob_1 == kLogZero<T>()) {
41 return log_prob_2;
42 } else if (log_prob_2 == kLogZero<T>()) {
43 return log_prob_1;
44 } else {
45 return (log_prob_1 > log_prob_2)
46 ? log_prob_1 + log1pf(expf(log_prob_2 - log_prob_1))
47 : log_prob_2 + log1pf(expf(log_prob_1 - log_prob_2));
48 }
49}
50
51} // namespace ctc
52} // namespace tensorflow

Callers 5

CalculateLossMethod · 0.70
CalculateGradientMethod · 0.70
StepMethod · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected