(query, story)
| 348 | # define one hop |
| 349 | # the "query" can be the question, or the answer from the previous hop |
| 350 | def hop(query, story): |
| 351 | # query.shape = (embedding_dim,) |
| 352 | # story.shape = (num sentences, embedding_dim) |
| 353 | x = Reshape((1, embedding_dim))(query) # make it (1, embedding_dim) |
| 354 | x = dot([story, x], 2) |
| 355 | x = Reshape((story_maxsents,))(x) # flatten it for softmax |
| 356 | x = Activation('softmax')(x) |
| 357 | story_weights = Reshape((story_maxsents, 1))(x) # unflatten for dotting |
| 358 | |
| 359 | # makes a new embedding |
| 360 | story_embedding2 = embed_and_sum(input_story_) |
| 361 | x = dot([story_weights, story_embedding2], 1) |
| 362 | x = Reshape((embedding_dim,))(x) |
| 363 | x = dense_layer(x) |
| 364 | return x, story_embedding2, story_weights |
| 365 | |
| 366 | |
| 367 | # do the hops |
no test coverage detected