def loop_continue_criterion(self, *args) -> tf.Tensor:
"""Decide whether to break out of the while loop.
Arguments:
loop_state: ``LoopState`` instance (see the docs for this module).
Represents current decoder loop state.
"""
loop_state = LoopState(*args)
finished = loop_state.feedables.finished
not_all_done = tf.logical_not(tf.reduce_all(finished))
before_max_len = tf.less(loop_state.feedables.step,
self.max_output_len)
return tf.logical_and(not_all_done, before_max_len)
评论列表
文章目录