(self, query, values, attn_mask=None)
| 62 | self.softmax = paddle.nn.Softmax(axis=-1) |
| 63 | |
| 64 | def forward(self, query, values, attn_mask=None): |
| 65 | # query shape: batch x query_size |
| 66 | # values shape: batch x num values x value_size |
| 67 | |
| 68 | # attn_logits shape: batch x num values |
| 69 | attn_logits = self.pointer(query, values, attn_mask) |
| 70 | # attn_logits shape: batch x num values |
| 71 | attn = self.softmax(attn_logits) |
| 72 | # output shape: batch x 1 x value_size |
| 73 | output = paddle.bmm(attn.unsqueeze(1), values) |
| 74 | output = output.squeeze(1) |
| 75 | return output, attn |
| 76 | |
| 77 | |
| 78 | class ScaledDotProductPointer(paddle.nn.Layer): |
nothing calls this directly
no outgoing calls
no test coverage detected