bshao001 / ChatLearner

A chatbot implemented in TensorFlow based on the seq2seq model, with certain rules integrated.
Apache License 2.0
538 stars 212 forks source link

issue: decode output layer #56

Closed zhupeiru closed 6 years ago

zhupeiru commented 6 years ago

hi Bo Shao, thanks for your public code. I am a new learner and I have learned much from it. I have one doubt: the output layer of decode. The following is yours in the file 'modelcreator.py':

#Decoder
my_decoder = tf.contrib.seq2seq.BasicDecoder(
    cell,
    helper,
    decoder_initial_state,)

# Dynamic decoding
outputs, final_context_state, _ = tf.contrib.seq2seq.dynamic_decode(
    my_decoder,
    output_time_major=self.time_major,
    swap_memory=True,
    scope=decoder_scope)

sample_id = outputs.sample_id
logits = self.output_layer(outputs.rnn_output)

I think the code should be like this:

#Decoder
my_decoder = tf.contrib.seq2seq.BasicDecoder(
    cell,
    helper,
    decoder_initial_state,
    output_layer=projection_layer)

# Dynamic decoding
outputs, final_context_state, _ = tf.contrib.seq2seq.dynamic_decode(
    my_decoder,
    output_time_major=self.time_major,
    swap_memory=True,
    scope=decoder_scope)

logits = outputs.rnn_output
zhupeiru commented 6 years ago

I am wrong...haha. In the predict, you add output_layer in the BasicDecoder.