1
1
function mbconv_builder (block_configs:: AbstractVector{NTuple{6, Int}} ,
2
2
stage_idx:: Integer ; scalings:: NTuple{2, Real} = (1 , 1 ),
3
3
norm_layer = BatchNorm)
4
- depth_mult, width_mult = scalings
4
+ width_mult, depth_mult = scalings
5
5
k, inplanes, outplanes, expansion, stride, nrepeats = block_configs[stage_idx]
6
6
inplanes = _round_channels (inplanes * width_mult, 8 )
7
7
outplanes = _round_channels (outplanes * width_mult, 8 )
@@ -17,7 +17,8 @@ function mbconv_builder(block_configs::AbstractVector{NTuple{6, Int}},
17
17
end
18
18
19
19
function fused_mbconv_builder (block_configs:: AbstractVector{NTuple{6, Int}} ,
20
- stage_idx:: Integer ; norm_layer = BatchNorm)
20
+ stage_idx:: Integer ; scalings:: NTuple{2, Real} = (1 , 1 ),
21
+ norm_layer = BatchNorm)
21
22
k, inplanes, outplanes, expansion, stride, nrepeats = block_configs[stage_idx]
22
23
function get_layers (block_idx)
23
24
inplanes = block_idx == 1 ? inplanes : outplanes
40
41
41
42
function efficientnet (block_configs:: AbstractVector{NTuple{6, Int}} ,
42
43
residual_fns:: AbstractVector ; scalings:: NTuple{2, Real} = (1 , 1 ),
43
- headplanes:: Integer = _round_channels (block_configs[end ][3 ] *
44
- scalings[2 ], 8 ) * 4 ,
44
+ headplanes:: Integer = block_configs[end ][3 ] * 4 ,
45
45
norm_layer = BatchNorm, dropout_rate = nothing ,
46
46
inchannels:: Integer = 3 , nclasses:: Integer = 1000 )
47
47
layers = []
48
48
# stem of the model
49
49
append! (layers,
50
- conv_norm ((3 , 3 ), inchannels, block_configs[1 ][2 ], swish; norm_layer,
51
- stride = 2 , pad = SamePad ()))
50
+ conv_norm ((3 , 3 ), inchannels,
51
+ _round_channels (block_configs[1 ][2 ] * scalings[1 ], 8 ), swish;
52
+ norm_layer, stride = 2 , pad = SamePad ()))
52
53
# building inverted residual blocks
53
54
get_layers, block_repeats = efficientnet_builder (block_configs, residual_fns;
54
55
scalings, norm_layer)
55
56
append! (layers, resnet_stages (get_layers, block_repeats, + ))
56
57
# building last layers
57
58
append! (layers,
58
- conv_norm ((1 , 1 ), _round_channels (block_configs[end ][3 ] * scalings[2 ], 8 ),
59
+ conv_norm ((1 , 1 ), _round_channels (block_configs[end ][3 ] * scalings[1 ], 8 ),
59
60
headplanes, swish; pad = SamePad ()))
60
61
return Chain (Chain (layers... ), create_classifier (headplanes, nclasses; dropout_rate))
61
62
end
0 commit comments