| 6 | def forward(self,x): |
| 7 | return x * torch.sigmoid(x) |
| 8 | class SE3d(nn.Module): |
| 9 | def __init__(self, channel, reduction=8, use_relu=False): |
| 10 | super().__init__() |
| 11 | self.fc = nn.Sequential( |
| 12 | nn.Linear(channel, channel // reduction, bias=False), |
| 13 | nn.ReLU(True) if use_relu else Swish() , |
| 14 | nn.Linear(channel // reduction, channel, bias=False), |
| 15 | nn.Sigmoid() |
| 16 | ) |
| 17 | |
| 18 | def forward(self, inputs): |
| 19 | return inputs * self.fc(inputs.mean(-1).mean(-1).mean(-1)).view(inputs.shape[0], inputs.shape[1], 1, 1, 1) |