(self, dec_input, s, join)
| 105 | self.dropout = nn.Dropout(dropout) |
| 106 | |
| 107 | def forward(self, dec_input, s, join): |
| 108 | dec_input = dec_input.unsqueeze(1).transpose(0, 1) |
| 109 | a = self.attention(s, join).unsqueeze(1) |
| 110 | # join |
| 111 | join = join.transpose(0, 1) |
| 112 | c = torch.bmm(a, join).transpose(0, 1) |
| 113 | rnn_input = torch.cat((dec_input, c), dim = 2) |
| 114 | dec_output, dec_state = self.rnn(rnn_input) |
| 115 | |
| 116 | if self.bidirectional: |
| 117 | dec_output = torch.add(dec_output[:,:,:self.hidden_dim],dec_output[:,:,self.hidden_dim:]) |
| 118 | h = torch.add(dec_state[0][-1],dec_state[0][-2]) |
| 119 | |
| 120 | dec_input = dec_input.squeeze(0) |
| 121 | dec_output = dec_output.squeeze(0) |
| 122 | c = c.squeeze(0) |
| 123 | |
| 124 | pred = self.fc_out(torch.cat((dec_output, c), dim = 1)) |
| 125 | |
| 126 | return pred, h.squeeze(0) |
| 127 | |
| 128 | |
| 129 | class MCTN(nn.Module): |
nothing calls this directly
no outgoing calls
no test coverage detected