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

Keep consistency in Classes ConvBNActivation #3750

Merged
merged 3 commits into from
Apr 28, 2021

Conversation

zhiqwang
Copy link
Contributor

@zhiqwang zhiqwang commented Apr 28, 2021

It seems that the class ConvBNReLU has been renamed to ConvBNActivation, but it still retains in the super(ConvBNReLU, self).__init__() method, it will make users a little confused, so I changed it to ConvBNActivation in this PR.

class ConvBNActivation(nn.Sequential):
def __init__(
self,
in_planes: int,
out_planes: int,
kernel_size: int = 3,
stride: int = 1,
groups: int = 1,
norm_layer: Optional[Callable[..., nn.Module]] = None,
activation_layer: Optional[Callable[..., nn.Module]] = None,
dilation: int = 1,
) -> None:
padding = (kernel_size - 1) // 2 * dilation
if norm_layer is None:
norm_layer = nn.BatchNorm2d
if activation_layer is None:
activation_layer = nn.ReLU6
super(ConvBNReLU, self).__init__(
nn.Conv2d(in_planes, out_planes, kernel_size, stride, padding, dilation=dilation, groups=groups,
bias=False),
norm_layer(out_planes),
activation_layer(inplace=True)
)
self.out_channels = out_planes

Copy link
Contributor

@datumbox datumbox left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good spot! I have indeed missed this when I changed it.

I left one optional recommendation for your consideration, let me know.

torchvision/models/mobilenetv2.py Outdated Show resolved Hide resolved
zhiqwang and others added 2 commits April 29, 2021 02:15
Co-authored-by: Vasilis Vryniotis <datumbox@users.noreply.github.com>
@prabhat00155 prabhat00155 merged commit cac8a97 into pytorch:master Apr 28, 2021
@zhiqwang zhiqwang deleted the consistency-classes branch April 29, 2021 00:09
facebook-github-bot pushed a commit that referenced this pull request May 4, 2021
Summary:
* Keep consistency of ConvBNActivation

* Simplify using the Python3 idiom

Reviewed By: NicolasHug

Differential Revision: D28169124

fbshipit-source-id: 5ed3ec8b5db9d8c0cc32a9ddcac51f6e680dcd69

Co-authored-by: Vasilis Vryniotis <datumbox@users.noreply.github.com>
Co-authored-by: Vasilis Vryniotis <datumbox@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants