Created by: guoshengCS
Fix and enhance beam_search_op and beam_searc_decode_op
Refer the source sentence as beam and the hypothesis as branch, then some points of the fix and enhancement are as following:
- beam_search_op:
- The ended branch should not be pruned since it still might be sifted out because of low score.
- Force the prediction of ended branch to allocate all probability mass to end token.
- Though the ended branch cann't be pruned , the ended beam whose branches are all finished can be pruned.
- beam_search_decode_op:
- Constructs the full hypotheses for each source sentence by walking back along the LoDTensorArray Input(ids).
- Sort the hypotheses of each source sentence by their scores.