MCPcopy Create free account
hub / github.com/PaddlePaddle/Research / forward

Method forward

NLP/Text2SQL-BASELINE/text2sql/models/attention.py:64–75  ·  view source on GitHub ↗
(self, query, values, attn_mask=None)

Source from the content-addressed store, hash-verified

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
78class ScaledDotProductPointer(paddle.nn.Layer):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected