@@ -23,16 +23,18 @@ Create a MobileNetv1 model ([reference](https://arxiv.org/abs/1704.04861v1)).
2323"""
2424function mobilenetv1 (config:: AbstractVector{<:Tuple} ; width_mult:: Real = 1 ,
2525 activation = relu, dropout_rate = nothing ,
26- inchannels:: Integer = 3 , nclasses:: Integer = 1000 )
26+ inplanes:: Integer = 32 , inchannels:: Integer = 3 ,
27+ nclasses:: Integer = 1000 )
2728 layers = []
2829 # stem of the model
30+ inplanes = floor (Int, inplanes * width_mult)
2931 append! (layers,
30- conv_norm ((3 , 3 ), inchannels, config[ 1 ][ 3 ] , activation; stride = 2 , pad = 1 ))
32+ conv_norm ((3 , 3 ), inchannels, inplanes , activation; stride = 2 , pad = 1 ))
3133 # building inverted residual blocks
32- get_layers, block_repeats = mbconv_stack_builder (config, config[ 1 ][ 3 ] ; width_mult)
34+ get_layers, block_repeats = mbconv_stack_builder (config, inplanes ; width_mult)
3335 append! (layers, cnn_stages (get_layers, block_repeats))
34- return Chain ( Chain (layers ... ),
35- create_classifier (config[ end ][ 3 ] , nclasses; dropout_rate))
36+ outplanes = floor (Int, config[ end ][ 3 ] * width_mult)
37+ return Chain ( Chain (layers ... ), create_classifier (outplanes , nclasses; dropout_rate))
3638end
3739
3840# Layer configurations for MobileNetv1
4547const MOBILENETV1_CONFIGS = [
4648 # f, k, c, s, n, a
4749 (dwsep_conv_bn, 3 , 64 , 1 , 1 , relu6),
48- (dwsep_conv_bn, 3 , 128 , 2 , 1 , relu6),
49- (dwsep_conv_bn, 3 , 128 , 1 , 1 , relu6),
50- (dwsep_conv_bn, 3 , 256 , 2 , 1 , relu6),
51- (dwsep_conv_bn, 3 , 256 , 1 , 1 , relu6),
52- (dwsep_conv_bn, 3 , 512 , 2 , 1 , relu6),
53- (dwsep_conv_bn, 3 , 512 , 1 , 5 , relu6),
54- (dwsep_conv_bn, 3 , 1024 , 2 , 1 , relu6),
55- (dwsep_conv_bn, 3 , 1024 , 1 , 1 , relu6),
50+ (dwsep_conv_bn, 3 , 128 , 2 , 2 , relu6),
51+ (dwsep_conv_bn, 3 , 256 , 2 , 2 , relu6),
52+ (dwsep_conv_bn, 3 , 512 , 2 , 6 , relu6),
53+ (dwsep_conv_bn, 3 , 1024 , 2 , 2 , relu6),
5654]
5755
5856"""
0 commit comments