5

I'm trying to implement a QA system following the instructions showed on this paper. I've correctly imported some datasets and converted the words in vectors with the word2vec method. After the word embedding there is the need to insert the questions and the answers in a CNN. What should be the size of the input Tensor given that each question/answer has a different length? (each question/answer is an array of vectors).

Excerpt from paper:

enter image description here

q_emb is the question after the word embedding and r_w_k is a word vector of length d.

Which is the right value of M (the length of the Q/A) that should be used? Can you please show me some methods to solve this issue or simply give me some help? Thank you

xdurch0
  • 7,274
  • 4
  • 25
  • 32
Luca Di Liello
  • 1,064
  • 10
  • 27

1 Answers1

3

Determine the maximum question/answer vector array length and make your input tensor of shape (num_samples, max_qa_length, word_embedding_size). For questions shorter than max_qa_length, pad them with zero vectors at the end.

warpri81
  • 566
  • 2
  • 5
  • Thanks for your answer. And what about creating the Z vector? In your opinion, will be better to create it before giving it to the NN as a tensor or in the network? – Luca Di Liello Aug 24 '18 at 13:05
  • You will want to do the padding before you feed it to TensorFlow, otherwise it will complain about the shape of your input. – warpri81 Aug 24 '18 at 16:01