(self, x)
| 170 | self.conv = nn.Conv2d(2, 1, kernel_size, padding=kernel_size // 2) |
| 171 | |
| 172 | def forward(self, x): |
| 173 | avg_out = torch.mean(x, dim=1, keepdim=True) |
| 174 | max_out, _ = torch.max(x, dim=1, keepdim=True) |
| 175 | attention = torch.cat([avg_out, max_out], dim=1) |
| 176 | attention = torch.sigmoid(self.conv(attention)) |
| 177 | return x * attention |
| 178 | |
| 179 | class CBAM(nn.Module): |
| 180 | def __init__(self, channels, reduction=16, kernel_size=7): |
nothing calls this directly
no outgoing calls
no test coverage detected