in utils/gluon/utils/mobilenetv2.py [0:0]
def __init__(self, in_planes, mid_planes, out_planes, strides=1,
norm_kwargs=None, last_gamma=False, name_prefix=None,
**kwargs):
super(_BottleneckV1, self).__init__(prefix=name_prefix)
self.use_shortcut = strides == 1 and in_planes == out_planes
with self.name_scope():
num_group = sum((c if c > 0 else 0 for c in mid_planes))
# extract information
self.conv1 = nn.Conv2D(channels=mid_planes, in_channels=in_planes,
kernel_size=1, use_bias=False, prefix='conv1')
self.bn1 = nn.BatchNorm(in_channels=mid_planes, prefix='bn1',
**({} if norm_kwargs is None else norm_kwargs))
self.relu1 = _op_act('relu6')
# capture spatial relations
self.conv2 = nn.Conv2D(channels=mid_planes, in_channels=mid_planes,
kernel_size=3, padding=1, groups=num_group,
strides=strides, use_bias=False, prefix='conv2')
self.bn2 = nn.BatchNorm(in_channels=mid_planes, prefix='bn2',
**({} if norm_kwargs is None else norm_kwargs))
self.relu2 = _op_act('relu6')
# embeding back to information highway
self.conv3 = nn.Conv2D(channels=out_planes, in_channels=mid_planes,
kernel_size=1, use_bias=False, prefix='conv3')
self.bn3 = nn.BatchNorm(in_channels=out_planes, prefix='bn3',
gamma_initializer='zeros' if (last_gamma and \
self.use_shortcut) else 'ones',
**({} if norm_kwargs is None else norm_kwargs))