(self, x)
| 26 | weight_init(layer) |
| 27 | |
| 28 | def forward(self, x): |
| 29 | m_batchsize, C, length, _ = x.size() |
| 30 | proj_value = self.value_conv(x).view(m_batchsize, -1, length) |
| 31 | x = proj_value.view(m_batchsize, -1, length, 1) |
| 32 | proj_query = self.query_conv(x).view(m_batchsize, -1, length).permute(0, 2, 1) |
| 33 | proj_key = self.key_conv(x).view(m_batchsize, -1, length) |
| 34 | energy = torch.bmm(proj_query, proj_key) |
| 35 | attention = self.softmax(energy) |
| 36 | x = torch.bmm(proj_value, attention.permute(0, 2, 1)) |
| 37 | x = torch.cat((self.gamma*x, proj_value), dim=1).view(m_batchsize, -1, length, 1) |
| 38 | return x |
| 39 | |
| 40 | |
| 41 | class OAM_GRAM(Module): |
nothing calls this directly
no outgoing calls
no test coverage detected