提交 4e4f36ac 编写于 作者: G guosheng

Add handle of tracks_own_finished in DynamicDecode

上级 2292264a
...@@ -521,7 +521,15 @@ class DynamicDecode(Layer): ...@@ -521,7 +521,15 @@ class DynamicDecode(Layer):
(step_outputs, next_states, next_inputs, (step_outputs, next_states, next_inputs,
next_finished) = self.decoder.step(step_idx_tensor, inputs, next_finished) = self.decoder.step(step_idx_tensor, inputs,
states, **kwargs) states, **kwargs)
next_finished = layers.logical_or(next_finished, finished) if not self.decoder.tracks_own_finished:
# BeamSearchDecoder would track it own finished, since
# beams would be reordered and the finished status of each
# entry might change. Otherwise, perform logical OR which
# would not change the already finished.
next_finished = layers.logical_or(next_finished, finished)
# To confirm states.finished/finished be consistent with
# next_finished.
layers.assign(next_finished, finished)
next_sequence_lengths = layers.elementwise_add( next_sequence_lengths = layers.elementwise_add(
sequence_lengths, sequence_lengths,
layers.cast( layers.cast(
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册