def vectorizeValData(xContext, xQuestion, word_index, context_maxlen, question_maxlen):
'''Vectorize the words to their respective index and pad context to max context length and question to max question length.
Answers vectors are padded to the max context length as well.
'''
X = []
Xq = []
YBegin = []
YEnd = []
for i in xrange(len(xContext)):
x = [word_index[w] for w in xContext[i]]
xq = [word_index[w] for w in xQuestion[i]]
X.append(x)
Xq.append(xq)
return pad_sequences(X, maxlen=context_maxlen, padding='post'), pad_sequences(Xq, maxlen=question_maxlen, padding='post')
QnARecurAtteLatest.py 文件源码
python
阅读 29
收藏 0
点赞 0
评论 0
评论列表
文章目录