Skip to content

Commit bda527b

Browse files
committed
Fix minor hiccups
1 parent c998951 commit bda527b

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

src/convnets/efficientnets/core.jl

+8-7
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
function mbconv_builder(block_configs::AbstractVector{NTuple{6, Int}},
22
stage_idx::Integer; scalings::NTuple{2, Real} = (1, 1),
33
norm_layer = BatchNorm)
4-
depth_mult, width_mult = scalings
4+
width_mult, depth_mult = scalings
55
k, inplanes, outplanes, expansion, stride, nrepeats = block_configs[stage_idx]
66
inplanes = _round_channels(inplanes * width_mult, 8)
77
outplanes = _round_channels(outplanes * width_mult, 8)
@@ -17,7 +17,8 @@ function mbconv_builder(block_configs::AbstractVector{NTuple{6, Int}},
1717
end
1818

1919
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)
2122
k, inplanes, outplanes, expansion, stride, nrepeats = block_configs[stage_idx]
2223
function get_layers(block_idx)
2324
inplanes = block_idx == 1 ? inplanes : outplanes
@@ -40,22 +41,22 @@ end
4041

4142
function efficientnet(block_configs::AbstractVector{NTuple{6, Int}},
4243
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,
4545
norm_layer = BatchNorm, dropout_rate = nothing,
4646
inchannels::Integer = 3, nclasses::Integer = 1000)
4747
layers = []
4848
# stem of the model
4949
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()))
5253
# building inverted residual blocks
5354
get_layers, block_repeats = efficientnet_builder(block_configs, residual_fns;
5455
scalings, norm_layer)
5556
append!(layers, resnet_stages(get_layers, block_repeats, +))
5657
# building last layers
5758
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),
5960
headplanes, swish; pad = SamePad()))
6061
return Chain(Chain(layers...), create_classifier(headplanes, nclasses; dropout_rate))
6162
end

src/convnets/efficientnets/efficientnetv2.jl

+2-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@ function EfficientNetv2(config::Symbol; pretrain::Bool = false,
5656
inchannels::Integer = 3, nclasses::Integer = 1000)
5757
_checkconfig(config, sort(collect(keys(EFFNETV2_CONFIGS))))
5858
layers = efficientnet(EFFNETV2_CONFIGS[config],
59-
vcat(fill(fused_mbconv_builder, 3), fill(mbconv_builder, 4));
59+
vcat(fill(fused_mbconv_builder, 3),
60+
fill(mbconv_builder, length(EFFNETV2_CONFIGS[config]) - 3));
6061
headplanes = 1280, inchannels, nclasses)
6162
if pretrain
6263
loadpretrain!(layers, string("efficientnetv2"))

0 commit comments

Comments
 (0)