Skip to content

Commit fb896c0

Browse files
committed
Update some comments re preliminary EfficientNet-V2 assumptions
1 parent 2b49ab7 commit fb896c0

File tree

2 files changed

+26
-5
lines changed

2 files changed

+26
-5
lines changed

timm/models/efficientnet.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -829,11 +829,16 @@ def _gen_efficientnet_v2s(variant, channel_multiplier=1.0, depth_multiplier=1.0,
829829
and weights
830830
831831
Ref impl:
832-
Paper: https://arxiv.org/abs/2104.00298
832+
Paper: `EfficientNetV2: Smaller Models and Faster Training` - https://arxiv.org/abs/2104.00298
833833
"""
834834

835835
arch_def = [
836-
['er_r2_k3_s1_e1_c24_noskip'],
836+
# FIXME it's not clear if the FusedMBConv layers have SE enabled for the Small variant,
837+
# Table 4 suggests no. 23.94M params w/o, 23.98 with which is closer to 24M.
838+
# ['er_r2_k3_s1_e1_c24_se0.25'],
839+
# ['er_r4_k3_s2_e4_c48_se0.25'],
840+
# ['er_r4_k3_s2_e4_c64_se0.25'],
841+
['er_r2_k3_s1_e1_c24'],
837842
['er_r4_k3_s2_e4_c48'],
838843
['er_r4_k3_s2_e4_c64'],
839844
['ir_r6_k3_s2_e4_c128_se0.25'],
@@ -846,7 +851,7 @@ def _gen_efficientnet_v2s(variant, channel_multiplier=1.0, depth_multiplier=1.0,
846851
stem_size=24,
847852
channel_multiplier=channel_multiplier,
848853
norm_kwargs=resolve_bn_args(kwargs),
849-
act_layer=resolve_act_layer(kwargs, 'silu'),
854+
act_layer=resolve_act_layer(kwargs, 'silu'), # FIXME this is an assumption, paper does not mention
850855
**kwargs,
851856
)
852857
model = _create_effnet(variant, pretrained, **model_kwargs)

timm/models/efficientnet_blocks.py

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,14 @@ def forward(self, x):
205205

206206

207207
class InvertedResidual(nn.Module):
208-
""" Inverted residual block w/ optional SE and CondConv routing"""
208+
""" Inverted residual block w/ optional SE
209+
210+
Originally used in MobileNet-V2 - https://arxiv.org/abs/1801.04381v4, this layer is often
211+
referred to as 'MBConv' for (Mobile inverted bottleneck conv) and is also used in
212+
* MNasNet - https://arxiv.org/abs/1807.11626
213+
* EfficientNet - https://arxiv.org/abs/1905.11946
214+
* MobileNet-V3 - https://arxiv.org/abs/1905.02244
215+
"""
209216

210217
def __init__(self, in_chs, out_chs, dw_kernel_size=3,
211218
stride=1, dilation=1, pad_type='', act_layer=nn.ReLU, noskip=False,
@@ -333,7 +340,16 @@ def forward(self, x):
333340

334341

335342
class EdgeResidual(nn.Module):
336-
""" Residual block with expansion convolution followed by pointwise-linear w/ stride"""
343+
""" Residual block with expansion convolution followed by pointwise-linear w/ stride
344+
345+
Originally introduced in `EfficientNet-EdgeTPU: Creating Accelerator-Optimized Neural Networks with AutoML`
346+
- https://ai.googleblog.com/2019/08/efficientnet-edgetpu-creating.html
347+
348+
This layer is also called FusedMBConv in the MobileDet, EfficientNet-X, and EfficientNet-V2 papers
349+
* MobileDet - https://arxiv.org/abs/2004.14525
350+
* EfficientNet-X - https://arxiv.org/abs/2102.05610
351+
* EfficientNet-V2 - https://arxiv.org/abs/2104.00298
352+
"""
337353

338354
def __init__(self, in_chs, out_chs, exp_kernel_size=3, exp_ratio=1.0, fake_in_chs=0,
339355
stride=1, dilation=1, pad_type='', act_layer=nn.ReLU, noskip=False, pw_kernel_size=1,

0 commit comments

Comments
 (0)