1

I'm running the ConvS2S example, the model trains just fine, but the inference code it's not clear enough, why does the prediction arrays have the length of the inputs_texts? My predictions output gibberish, I'm clearly doing something wrong, since my model seems to learn quite, well.

Thanks in advance.

As far as I can tell the prediction array should be something like:

The original source is this:

nb_examples = 100
in_encoder = encoder_input_data[:nb_examples]
in_decoder = np.zeros((len(input_texts), max_decoder_seq_length, num_decoder_tokens), dtype='float32')

in_decoder[:, 0, target_token_index["\t"]] = 1

predict = np.zeros((len(input_texts), max_decoder_seq_length), dtype='float32')

But why use len(input_texts)?

amiabl
  • 1,047
  • 19
  • 27
Pedro Lima
  • 93
  • 2
  • 5
  • You may want to add a pointer to the seq2seq example you are referring to. There are multiple implementations out there. The way I read your code snippet input_texts is an array / sequence of phrases; if that is the case then you would want a prediction for each sentence thus the output would be shaped as (number of sentences, sentence length). – Pedro Marques Jul 20 '19 at 10:17
  • The example is this one in the Keras-Examples: https://github.com/keras-team/keras/blob/master/examples/cnn_seq2seq.py – Pedro Lima Jul 20 '19 at 11:32
  • input_texts is a list with all input examples, my question is why is that needed for inference? – Pedro Lima Jul 20 '19 at 11:33
  • len(input_texts) is actually wrong. It should be nb_examples. It doesn't really matter because the predict variable gets overwritten in the prediction loop. – Pedro Marques Jul 20 '19 at 11:39
  • Thanks, I think this is answer is really good thanks, I'm doing some testing right now with these changes. – Pedro Lima Jul 20 '19 at 11:53

0 Answers0