Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apply FReLU to MobileNetV3 #4

Open
panda1949 opened this issue Aug 6, 2020 · 2 comments
Open

Apply FReLU to MobileNetV3 #4

panda1949 opened this issue Aug 6, 2020 · 2 comments

Comments

@panda1949
Copy link

panda1949 commented Aug 6, 2020

I reimplemented FReLU in PyTorch, and apply it on MobileNetV3 by replacing all the hswish with frelu. The ImageNet accuracy is as follow:

model top1
mobilenetv3+hswish 75.2%
mobilenetv3+frelu 74.8%

My code:

class FReLU(nn.Module):
    def __init__(self, in_channels, inplace: bool = False):
        super(FReLU, self).__init__()
        self.inplace = inplace
        self.conv_frelu = nn.Conv2d(in_channels, in_channels, 3, 1, 1, groups=in_channels, bias=False)
        self.bn_frelu = nn.BatchNorm2d(in_channels)

    def forward(self, x):
        x1 = self.conv_frelu(x)
        x1 = self.bn_frelu(x1)
        x = torch.max(x, x1)
        return x

Am I missing something important? As for the gaussian initialization in FReLU, what's the std?

@nmaac
Copy link
Collaborator

nmaac commented Aug 10, 2020

We use gaussian initialization with std=0.01. I simply replace relu with frelu and it shows a slight improvement (0.1~0.3). We note that MobileNetV3 is a NAS-searched optimal CNN architecture, once you change the architecture (frelu has an additional dw-conv), you might need to search again on this new architecture to achieve the optimal result.

@panda1949
Copy link
Author

Thanks for your quick reply. I'll try your suggestions.

@nmaac nmaac changed the title Worse accuracy for MobileNetV3 Apply FReLU to MobileNetV3 Aug 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants