response = Sequential()
response.add(Merge([match, input_encoder_c], mode="sum"))
// output: (samples, story_maxlen, query_maxlen)
response.add(Permute((2, 1))) // output: (samples, query_maxlen, story_maxlen)
// concatenate the match vector with the question vector,
// and do logistic regression on top
After Change
// the original paper uses a matrix multiplication for this reduction step.
// we choose to use a RNN instead.
answer = LSTM(32)(answer) // (samples, 32)
// one regularization layer -- more would probably be needed.
answer = Dropout(0.3)(answer)
answer = Dense(vocab_size)(answer) // (samples, vocab_size)
// we output a probability distribution over the vocabulary
answer = Activation("softmax")(answer)
// build the final model
model = Model([input_sequence, question], answer)
model.compile(optimizer="rmsprop", loss="categorical_crossentropy",
metrics=["accuracy"])