You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There seems to be a small issue with the width multiplier in mobilenet v2. The official implementation rounds filter channels to a multiple of 8.
For example, mobilenet v2 width 1.4. The first conv layer has 44 channels as opposed to 48 in the official implementation:
model = torchvision.models.mobilenet_v2(width_mult=1.4)
for module in model.modules():
if isinstance(module, nn.Conv2d):
print(module.weight.shape)
There seems to be a small issue with the width multiplier in mobilenet v2. The official implementation rounds filter channels to a multiple of 8.
For example, mobilenet v2 width 1.4. The first conv layer has 44 channels as opposed to 48 in the official implementation:
model = torchvision.models.mobilenet_v2(width_mult=1.4)
for module in model.modules():
if isinstance(module, nn.Conv2d):
print(module.weight.shape)
torch.Size([44, 3, 3, 3])
torch.Size([44, 1, 3, 3])
torch.Size([22, 44, 1, 1])
torch.Size([132, 22, 1, 1])
torch.Size([132, 1, 3, 3])
torch.Size([33, 132, 1, 1])
Corresponding tensorflow 2.0 keras code:
model = tf.keras.applications.MobileNetV2(
weights="imagenet", input_shape=(224, 224, 3), alpha=1.4)
model.summary()
Layer (type) Output Shape Param # Connected to
input_1 (InputLayer) [(None, 224, 224, 3) 0
Conv1_pad (ZeroPadding2D) (None, 225, 225, 3) 0 input_1[0][0]
Conv1 (Conv2D) (None, 112, 112, 48) 1296 Conv1_pad[0][0]
bn_Conv1 (BatchNormalization) (None, 112, 112, 48) 192 Conv1[0][0]
Conv1_relu (ReLU) (None, 112, 112, 48) 0 bn_Conv1[0][0]
expanded_conv_depthwise (Depthw (None, 112, 112, 48) 432 Conv1_relu[0][0]
expanded_conv_depthwise_BN (Bat (None, 112, 112, 48) 192 expanded_conv_depthwise[0][0]
expanded_conv_depthwise_relu (R (None, 112, 112, 48) 0 expanded_conv_depthwise_BN[0][0]
expanded_conv_project (Conv2D) (None, 112, 112, 24) 1152 expanded_conv_depthwise_relu[0][0
expanded_conv_project_BN (Batch (None, 112, 112, 24) 96 expanded_conv_project[0][0]
block_1_expand (Conv2D) (None, 112, 112, 144 3456 expanded_conv_project_BN[0][0]
block_1_expand_BN (BatchNormali (None, 112, 112, 144 576 block_1_expand[0][0]
block_1_expand_relu (ReLU) (None, 112, 112, 144 0 block_1_expand_BN[0][0]
block_1_pad (ZeroPadding2D) (None, 113, 113, 144 0 block_1_expand_relu[0][0]
block_1_depthwise (DepthwiseCon (None, 56, 56, 144) 1296 block_1_pad[0][0]
block_1_depthwise_BN (BatchNorm (None, 56, 56, 144) 576 block_1_depthwise[0][0]
block_1_depthwise_relu (ReLU) (None, 56, 56, 144) 0 block_1_depthwise_BN[0][0]
block_1_project (Conv2D) (None, 56, 56, 32) 4608 block_1_depthwise_relu[0][0]
I've implemented a fix here:
https://github.com/yaysummeriscoming/vision/blob/master/torchvision/models/mobilenet.py
Can I merge it in?
The text was updated successfully, but these errors were encountered: