MCPcopy Create free account
hub / github.com/AtlasAnalyticsLab/AdaFisher / MobileNetV3

Class MobileNetV3

Image_Classification/src/models/mobilenetv3.py:160–325  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

158
159
160class MobileNetV3(nn.Module):
161 '''
162
163 '''
164
165 def __init__(self, mode='small', classes_num=1000, input_size=224, width_multiplier=1.0, dropout=0.2,
166 BN_momentum=0.1, zero_gamma=False):
167 '''
168 configs: setting of the model
169 mode: type of the model, 'large' or 'small'
170 '''
171 super(MobileNetV3, self).__init__()
172
173 mode = mode.lower()
174 assert mode in ['large', 'small']
175 s = 2
176 if input_size == 32 or input_size == 56:
177 # using cifar-10, cifar-100 or Tiny-ImageNet
178 s = 1
179
180 # setting of the model
181 if mode == 'large':
182 # Configuration of a MobileNetV3-Large Model
183 configs = [
184 # kernel_size, exp_size, out_channels_num, use_SE, NL, stride
185 [3, 16, 16, False, 'RE', 1],
186 [3, 64, 24, False, 'RE', s],
187 [3, 72, 24, False, 'RE', 1],
188 [5, 72, 40, True, 'RE', 2],
189 [5, 120, 40, True, 'RE', 1],
190 [5, 120, 40, True, 'RE', 1],
191 [3, 240, 80, False, 'HS', 2],
192 [3, 200, 80, False, 'HS', 1],
193 [3, 184, 80, False, 'HS', 1],
194 [3, 184, 80, False, 'HS', 1],
195 [3, 480, 112, True, 'HS', 1],
196 [3, 672, 112, True, 'HS', 1],
197 [5, 672, 160, True, 'HS', 2],
198 [5, 960, 160, True, 'HS', 1],
199 [5, 960, 160, True, 'HS', 1]
200 ]
201 elif mode == 'small':
202 # Configuration of a MobileNetV3-Small Model
203 configs = [
204 # kernel_size, exp_size, out_channels_num, use_SE, NL, stride
205 [3, 16, 16, True, 'RE', s],
206 [3, 72, 24, False, 'RE', 2],
207 [3, 88, 24, False, 'RE', 1],
208 [5, 96, 40, True, 'HS', 2],
209 [5, 240, 40, True, 'HS', 1],
210 [5, 240, 40, True, 'HS', 1],
211 [5, 120, 48, True, 'HS', 1],
212 [5, 144, 48, True, 'HS', 1],
213 [5, 288, 96, True, 'HS', 2],
214 [5, 576, 96, True, 'HS', 1],
215 [5, 576, 96, True, 'HS', 1]
216 ]
217

Callers 1

mobilenetv3Function · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected