(self, dim, reduction=1)
| 8 | # Feature Rectify Module |
| 9 | class ChannelWeights(nn.Module): |
| 10 | def __init__(self, dim, reduction=1): |
| 11 | super(ChannelWeights, self).__init__() |
| 12 | self.dim = dim |
| 13 | self.avg_pool = nn.AdaptiveAvgPool2d(1) |
| 14 | self.max_pool = nn.AdaptiveMaxPool2d(1) |
| 15 | self.mlp = nn.Sequential( |
| 16 | nn.Linear(self.dim * 4, self.dim * 4 // reduction), |
| 17 | nn.ReLU(inplace=True), |
| 18 | nn.Linear(self.dim * 4 // reduction, self.dim * 2), |
| 19 | nn.Sigmoid(), |
| 20 | ) |
| 21 | |
| 22 | def forward(self, x1, x2): |
| 23 | B, _, H, W = x1.shape |