szha commented on a change in pull request #9614: MobileNetV2
URL: https://github.com/apache/incubator-mxnet/pull/9614#discussion_r165440508
##########
File path: python/mxnet/gluon/model_zoo/vision/mobilenet.py
##########
@@ -17,27 +17,72 @@
# coding: utf-8
# pylint: disable= arguments-differ
-"""MobileNet, implemented in Gluon."""
-__all__ = ['MobileNet', 'mobilenet1_0', 'mobilenet0_75', 'mobilenet0_5',
'mobilenet0_25',
- 'get_mobilenet']
+"""MobileNet and MobileNetV2, implemented in Gluon."""
+__all__ = ['MobileNet', 'MobileNetV2', 'mobilenet1_0', 'mobilenet0_75',
+ 'mobilenet0_5', 'mobilenet0_25', 'get_mobilenet']
+
+__modify__ = 'dwSun'
+__modified_date__ = '18/01/31'
import os
+from ... import nn
from ....context import cpu
from ...block import HybridBlock
-from ... import nn
+
# Helpers
+# pylint: disable= too-many-arguments
def _add_conv(out, channels=1, kernel=1, stride=1, pad=0, num_group=1):
out.add(nn.Conv2D(channels, kernel, stride, pad, groups=num_group,
use_bias=False))
out.add(nn.BatchNorm(scale=True))
out.add(nn.Activation('relu'))
+
def _add_conv_dw(out, dw_channels, channels, stride):
_add_conv(out, channels=dw_channels, kernel=3, stride=stride, pad=1,
num_group=dw_channels)
_add_conv(out, channels=channels)
+class BottleNeck(nn.HybridBlock):
+ r"""BottleNeck used in MobileNetV2 model from the
+ `"Inverted Residuals and Linear Bottlenecks:
+ Mobile Networks for Classification, Detection and Segmentation"
+ <https://arxiv.org/abs/1801.04381>`_ paper.
+
+ Parameters
+ ----------
+ c_in : int
+ Number of input channels.
+ c_out : int
+ Number of output channels.
+ t : int
+ Layer expansion ratio.
+ s : int
+ strides
Review comment:
Use the argument naming from
https://github.com/apache/incubator-mxnet/blob/master/python/mxnet/gluon/model_zoo/vision/resnet.py#L95-L102
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services