(self, input_dimension, attention_dimension, device, dropout=0)
| 25 | """ |
| 26 | |
| 27 | def __init__(self, input_dimension, attention_dimension, device, dropout=0): |
| 28 | super(SumAttention, self).__init__() |
| 29 | self.attention_matrix = \ |
| 30 | torch.nn.Linear(input_dimension, attention_dimension).to(device) |
| 31 | self.attention_vector = torch.nn.Linear(attention_dimension, 1, bias=False).to(device) |
| 32 | init_tensor(self.attention_matrix.weight) |
| 33 | init_tensor(self.attention_vector.weight) |
| 34 | self.dropout = torch.nn.Dropout(p=dropout) |
| 35 | |
| 36 | def forward(self, inputs): |
| 37 | if inputs.size(1) == 1: |
nothing calls this directly
no test coverage detected