MCPcopy Create free account
hub / github.com/pytorch/tutorials / concat_score

Method concat_score

beginner_source/chatbot_tutorial.py:763–765  ·  view source on GitHub ↗
(self, hidden, encoder_output)

Source from the content-addressed store, hash-verified

761 return torch.sum(hidden * energy, dim=2)
762
763 def concat_score(self, hidden, encoder_output):
764 energy = self.attn(torch.cat((hidden.expand(encoder_output.size(0), -1, -1), encoder_output), 2)).tanh()
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

Callers 1

forwardMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected