简体   繁体   中英

TrainingHelper in Tensorflow seq2seq don't use start token as the initial input?

In my understand, the first input of the decoder for seq2seq model is the start token. But when I read the code from TrainingHelper in tensorflow/contrib/seq2seq/python/ops/helper.py , I found it just return the first token of the target tokens as the first token:

  def initialize(self, name=None):
    with ops.name_scope(name, "TrainingHelperInitialize"):
      finished = math_ops.equal(0, self._sequence_length)
      all_finished = math_ops.reduce_all(finished)
      next_inputs = control_flow_ops.cond(
          all_finished, lambda: self._zero_inputs,
          lambda: nest.map_structure(lambda inp: inp.read(0), self._input_tas))
      return (finished, next_inputs)

Is that right?

Em... I have worked around nlp many times including seq2seq translation. But I have never heard about start token but only end token( EOF ).

Although my seq2seq task worked well without anything like start token, I'm not sure if it is a new technique. If it is, thank you let me know.

事实证明,您需要自己添加启动令牌,然后才能将其输入到TrainHelper中

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM