(self, hidden, encoder_outputs)
| 765 | return torch.sum(self.v * energy, dim=2) |
| 766 | |
| 767 | def forward(self, hidden, encoder_outputs): |
| 768 | # Calculate the attention weights (energies) based on the given method |
| 769 | if self.method == 'general': |
| 770 | attn_energies = self.general_score(hidden, encoder_outputs) |
| 771 | elif self.method == 'concat': |
| 772 | attn_energies = self.concat_score(hidden, encoder_outputs) |
| 773 | elif self.method == 'dot': |
| 774 | attn_energies = self.dot_score(hidden, encoder_outputs) |
| 775 | |
| 776 | # Transpose max_length and batch_size dimensions |
| 777 | attn_energies = attn_energies.t() |
| 778 | |
| 779 | # Return the softmax normalized probability scores (with added dimension) |
| 780 | return F.softmax(attn_energies, dim=1).unsqueeze(1) |
| 781 | |
| 782 | |
| 783 | ###################################################################### |
nothing calls this directly
no test coverage detected