| 59 | |
| 60 | class SelfAttention(torch.nn.Module): |
| 61 | def __init__(self, args): |
| 62 | super(SelfAttention,self).__init__() |
| 63 | self.args = args |
| 64 | self.linear_q = torch.nn.Linear(args.lstm_dim * 2, args.lstm_dim * 2) |
| 65 | # self.linear_k = torch.nn.Linear(configs.BILSTM_DIM * 2, configs.BILSTM_DIM * 2) |
| 66 | # self.linear_v = torch.nn.Linear(configs.BILSTM_DIM * 2, configs.BILSTM_DIM * 2) |
| 67 | # self.w_query = torch.nn.Linear(configs.BILSTM_DIM * 2, 50) |
| 68 | # self.w_value = torch.nn.Linear(configs.BILSTM_DIM * 2, 50) |
| 69 | self.w_query = torch.nn.Linear(args.cnn_dim, 50) |
| 70 | self.w_value = torch.nn.Linear(args.cnn_dim, 50) |
| 71 | self.v = torch.nn.Linear(50, 1, bias=False) |
| 72 | |
| 73 | def forward(self, query, value, mask): |
| 74 | # attention_states = self.linear_q(query) |