I'm trying to build a basic encoder-decoder model. I build the model for training graph and it works perfect. The helper of the decoder is tf.contrib.seq2seq.TrainingHelper
. But when I switch to helper to tf.contrib.seq2seq.GreedyEmbeddingHelper
it throws a shape error.
Here it is my working helper.
helper = tf.contrib.seq2seq.TrainingHelper(
decoder_emb_inp, decoder_lengths, time_major=True)
And here it is the what I want to do.
start_tokens = tf.fill([batch_size], vezins_dict[start_token_str])
end_token = vezins_dict[end_token_str]
helper = tf.contrib.seq2seq.GreedyEmbeddingHelper(decoder_emb_inp,
start_tokens, end_token)
I am using the same decoder and dynamic_decoding. It works with TrainingHelper
, but it didn't work with GreedyEmbeddingHelper
.
# decoder
decoder = tf.contrib.seq2seq.BasicDecoder(
decoder_cell, helper, encoder_state,
output_layer=projection_layer)
# Dynamic decoding
outputs, _, _ = tf.contrib.seq2seq.dynamic_decode(decoder)
logits = outputs.rnn_output
And here it is the error.
ValueError: linear is expecting 2D arguments:
[TensorShape([Dimension(20), Dimension(20), Dimension(10)]),
TensorShape([Dimension(20), Dimension(128)])]