ematvey / tensorflow-seq2seq-tutorials

Dynamic seq2seq in TensorFlow, step by step

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

there is no input argument when loop_fn method is called.

hsh2438 opened this issue · comments

I am studying Advanced dynamic seq2seq with TensorFlow.
When i executed source code, it works well.
But i have a question among the below source code.

In [21]:

def loop_fn(time, previous_output, previous_state, previous_loop_state):
    if previous_state is None:    # time == 0
        assert previous_output is None and previous_state is None
        return loop_fn_initial()
    else:
        return loop_fn_transition(time, previous_output, previous_state, previous_loop_state)

decoder_outputs_ta, decoder_final_state, _ = tf.nn.raw_rnn(decoder_cell, loop_fn)
decoder_outputs = decoder_outputs_ta.stack()

decoder_outputs_ta, decoder_final_state, _ = tf.nn.raw_rnn(decoder_cell, loop_fn)

Above bolded line call loop_fn method, but there's no input argument.
Then, i wonder how loop_fn method works well.

Check out loop_fn_transition above, it feeds PAD token at the 1 decoding step, then feeds previously generated tokens.