xiaolai-sqlai/mobilenetv3

The SE module is wrong, it's not just squeeze and expand the channel.

longxianlei opened this issue · 1 comments

You should use the avg_pool to the input x, and use fc-->fc and expand as the input x's dimension. Then use the shortcut connection.

self.avg_pool below is not called.

class SeModule(nn.Module):
    def __init__(self, in_size, reduction=4):
        super(SeModule, self).__init__()
        self.avg_pool = nn.AdaptiveAvgPool2d(1)

        self.se = nn.Sequential(
            nn.Conv2d(in_size, in_size // reduction, kernel_size=1, stride=1, padding=0, bias=False),
            nn.BatchNorm2d(in_size // reduction),
            nn.ReLU(inplace=True),
            nn.Conv2d(in_size // reduction, in_size, kernel_size=1, stride=1, padding=0, bias=False),
            nn.BatchNorm2d(in_size),
            hsigmoid()
        )

    def forward(self, x):
        return x * self.se(x)