diff --git a/include/detail/cpu_ctc.h b/include/detail/cpu_ctc.h index c272f24b658791..3f46a6c9f09a55 100644 --- a/include/detail/cpu_ctc.h +++ b/include/detail/cpu_ctc.h @@ -168,11 +168,13 @@ CpuCTC::softmax(const ProbT* const activations, ProbT* probs, max_activation = std::max(max_activation, activations[r + col_offset]); ProbT denom = ProbT(0.); - for(int r = 0; r < alphabet_size_; ++r) - denom += std::exp(activations[r + col_offset] - max_activation); + for(int r = 0; r < alphabet_size_; ++r) { + probs[r + col_offset] = std::exp(activations[r + col_offset] - max_activation); + denom += probs[r + col_offset]; + } for(int r = 0; r < alphabet_size_; ++r) { - probs[r + col_offset] = std::exp(activations[r + col_offset] - max_activation) / denom; + probs[r + col_offset] /= denom; } } }