Skip to content
This repository was archived by the owner on Nov 3, 2022. It is now read-only.

Commit a6d0e4d

Browse files
committed
Clean up an unused parameter in MobileNetV2 (#63)
1 parent 5f99f52 commit a6d0e4d

File tree

2 files changed

+8
-13
lines changed

2 files changed

+8
-13
lines changed

keras_applications/mobilenet.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,15 +105,16 @@ def MobileNet(input_shape=None,
105105
It should have exactly 3 inputs channels,
106106
and width and height should be no smaller than 32.
107107
E.g. `(200, 200, 3)` would be one valid value.
108-
alpha: controls the width of the network.
108+
alpha: controls the width of the network. This is known as the
109+
width multiplier in the MobileNet paper.
109110
- If `alpha` < 1.0, proportionally decreases the number
110111
of filters in each layer.
111112
- If `alpha` > 1.0, proportionally increases the number
112113
of filters in each layer.
113114
- If `alpha` = 1, default number of filters from the paper
114115
are used at each layer.
115-
depth_multiplier: depth multiplier for depthwise convolution
116-
(also called the resolution multiplier)
116+
depth_multiplier: depth multiplier for depthwise convolution. This
117+
is called the resolution multiplier in the MobileNet paper.
117118
dropout: dropout rate
118119
include_top: whether to include the fully-connected
119120
layer at the top of the network.

keras_applications/mobilenet_v2.py

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,6 @@ def _make_divisible(v, divisor, min_value=None):
126126

127127
def MobileNetV2(input_shape=None,
128128
alpha=1.0,
129-
depth_multiplier=1,
130129
include_top=True,
131130
weights='imagenet',
132131
input_tensor=None,
@@ -147,15 +146,14 @@ def MobileNetV2(input_shape=None,
147146
do not match then we will throw an error.
148147
E.g. `(160, 160, 3)` would be one valid value.
149148
alpha: controls the width of the network. This is known as the
150-
width multiplier in the MobileNetV2 paper.
149+
width multiplier in the MobileNetV2 paper, but the name is kept for
150+
consistency with MobileNetV1 in Keras.
151151
- If `alpha` < 1.0, proportionally decreases the number
152152
of filters in each layer.
153153
- If `alpha` > 1.0, proportionally increases the number
154154
of filters in each layer.
155155
- If `alpha` = 1, default number of filters from the paper
156156
are used at each layer.
157-
depth_multiplier: depth multiplier for depthwise convolution
158-
(also called the resolution multiplier)
159157
include_top: whether to include the fully-connected
160158
layer at the top of the network.
161159
weights: one of `None` (random initialization),
@@ -185,8 +183,8 @@ def MobileNetV2(input_shape=None,
185183
186184
# Raises
187185
ValueError: in case of invalid argument for `weights`,
188-
or invalid input shape or invalid depth_multiplier, alpha,
189-
rows when weights='imagenet'
186+
or invalid input shape or invalid alpha, rows when
187+
weights='imagenet'
190188
"""
191189
global backend, layers, models, keras_utils
192190
backend, layers, models, keras_utils = get_submodules_from_kwargs(kwargs)
@@ -286,10 +284,6 @@ def MobileNetV2(input_shape=None,
286284
cols = input_shape[col_axis]
287285

288286
if weights == 'imagenet':
289-
if depth_multiplier != 1:
290-
raise ValueError('If imagenet weights are being loaded, '
291-
'depth multiplier must be 1')
292-
293287
if alpha not in [0.35, 0.50, 0.75, 1.0, 1.3, 1.4]:
294288
raise ValueError('If imagenet weights are being loaded, '
295289
'alpha can be one of `0.35`, `0.50`, `0.75`, '

0 commit comments

Comments
 (0)