scaled_dot_product_matrix_attention
allennlp.modules.matrix_attention.scaled_dot_product_matrix_attention
ScaledDotProductMatrixAttention¶
@MatrixAttention.register("scaled_dot_product")
class ScaledDotProductMatrixAttention(DotProductMatrixAttention)
Computes attention between every entry in matrix_1 with every entry in matrix_2 using a dot product. Scales the result by the size of the embeddings.
Registered as a MatrixAttention
with name "scaled_dot_product".
forward¶
class ScaledDotProductMatrixAttention(DotProductMatrixAttention):
| ...
| def forward(
| self,
| matrix_1: torch.Tensor,
| matrix_2: torch.Tensor
| ) -> torch.Tensor