提交 36743d36 编写于 作者: Y Yibing Liu

add scoring last word in beam search

上级 ff01d048
...@@ -222,8 +222,11 @@ def ctc_beam_search_decoder(probs_seq, ...@@ -222,8 +222,11 @@ def ctc_beam_search_decoder(probs_seq,
beam_result = [] beam_result = []
for (seq, prob) in prefix_set_prev.items(): for (seq, prob) in prefix_set_prev.items():
if prob > 0.0: if prob > 0.0 and len(seq) > 1:
result = seq[1:] result = seq[1:]
# score last word by external scorer
if (ext_scoring_func is not None) and (result[-1] != ' '):
prob = prob * ext_scoring_func(result)
log_prob = np.log(prob) log_prob = np.log(prob)
beam_result.append([log_prob, result]) beam_result.append([log_prob, result])
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册