(self, x1, x2)
| 20 | ) |
| 21 | |
| 22 | def forward(self, x1, x2): |
| 23 | B, _, H, W = x1.shape |
| 24 | x = torch.cat((x1, x2), dim=1) |
| 25 | avg = self.avg_pool(x).view(B, self.dim * 2) |
| 26 | max = self.max_pool(x).view(B, self.dim * 2) |
| 27 | y = torch.cat((avg, max), dim=1) # B 4C |
| 28 | y = self.mlp(y).view(B, self.dim * 2, 1) |
| 29 | channel_weights = y.reshape(B, 2, self.dim, 1, 1).permute(1, 0, 2, 3, 4) # 2 B C 1 1 |
| 30 | return channel_weights |
| 31 | |
| 32 | |
| 33 | class SpatialWeights(nn.Module): |
nothing calls this directly
no outgoing calls
no test coverage detected