b5a02391e003c33c8f8258a7e3d0736503c3c048,examples/babi_memnn.py,,,#,97

Before Change


answer.add(Dropout(0.3))
answer.add(Dense(vocab_size))
// we output a probability distribution over the vocabulary
answer.add(Activation("softmax"))

answer.compile(optimizer="rmsprop", loss="categorical_crossentropy",
               metrics=["accuracy"])
// Note: you could use a Graph model to avoid repeat the input twice

After Change



// compute a "match" between the first input vector sequence
// and the question vector sequence
match = dot([input_encoded_m, question_encoded], axes=(2, 2))  // (samples, story_maxlen, query_maxlen)
match = Activation("softmax")(match)

// add the match matrix with the second input vector sequence
response = add([match, input_encoded_c])  // (samples, story_maxlen, query_maxlen)
response = Permute((2, 1))(response)  // (samples, query_maxlen, story_maxlen)

// concatenate the match matrix with the question vector sequence
answer = concatenate([response, question_encoded])

// 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",
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 3

Instances


Project Name: keras-team/keras
Commit Name: b5a02391e003c33c8f8258a7e3d0736503c3c048
Time: 2017-03-15
Author: farizrahman4u@gmail.com
File Name: examples/babi_memnn.py
Class Name:
Method Name:


Project Name: shenweichen/DeepCTR
Commit Name: 8182ea386e6529a1a2294d8e2d33fc040d0cbfb2
Time: 2019-07-21
Author: wcshen1994@163.com
File Name: deepctr/inputs.py
Class Name:
Method Name: get_linear_logit


Project Name: NTMC-Community/MatchZoo
Commit Name: 478d2f388dc65736b5d67f3560328904210ef1a1
Time: 2018-12-01
Author: i@uduse.com
File Name: matchzoo/models/arci_model.py
Class Name: ArcIModel
Method Name: get_default_params