@ -253,7 +253,7 @@ class EfficientNet(nn.Module):
def __init__ ( self , block_args , num_classes = 1000 , num_features = 1280 , in_chans = 3 , stem_size = 32 ,
channel_multiplier = 1.0 , channel_divisor = 8 , channel_min = None ,
output_stride = 32 , pad_type = ' ' , act_layer = nn . ReLU , drop_rate = 0. , drop_ connect _rate= 0. ,
output_stride = 32 , pad_type = ' ' , act_layer = nn . ReLU , drop_rate = 0. , drop_ path _rate= 0. ,
se_kwargs = None , norm_layer = nn . BatchNorm2d , norm_kwargs = None , global_pool = ' avg ' ) :
super ( EfficientNet , self ) . __init__ ( )
norm_kwargs = norm_kwargs or { }
@ -273,7 +273,7 @@ class EfficientNet(nn.Module):
# Middle stages (IR/ER/DS Blocks)
builder = EfficientNetBuilder (
channel_multiplier , channel_divisor , channel_min , output_stride , pad_type , act_layer , se_kwargs ,
norm_layer , norm_kwargs , drop_ connect _rate, verbose = _DEBUG )
norm_layer , norm_kwargs , drop_ path _rate, verbose = _DEBUG )
self . blocks = nn . Sequential ( * builder ( self . _in_chs , block_args ) )
self . feature_info = builder . features
self . _in_chs = builder . in_chs
@ -333,7 +333,7 @@ class EfficientNetFeatures(nn.Module):
def __init__ ( self , block_args , out_indices = ( 0 , 1 , 2 , 3 , 4 ) , feature_location = ' pre_pwl ' ,
in_chans = 3 , stem_size = 32 , channel_multiplier = 1.0 , channel_divisor = 8 , channel_min = None ,
output_stride = 32 , pad_type = ' ' , act_layer = nn . ReLU , drop_rate = 0. , drop_ connect _rate= 0. ,
output_stride = 32 , pad_type = ' ' , act_layer = nn . ReLU , drop_rate = 0. , drop_ path _rate= 0. ,
se_kwargs = None , norm_layer = nn . BatchNorm2d , norm_kwargs = None ) :
super ( EfficientNetFeatures , self ) . __init__ ( )
norm_kwargs = norm_kwargs or { }
@ -355,7 +355,7 @@ class EfficientNetFeatures(nn.Module):
# Middle stages (IR/ER/DS Blocks)
builder = EfficientNetBuilder (
channel_multiplier , channel_divisor , channel_min , output_stride , pad_type , act_layer , se_kwargs ,
norm_layer , norm_kwargs , drop_ connect _rate, feature_location = feature_location , verbose = _DEBUG )
norm_layer , norm_kwargs , drop_ path _rate, feature_location = feature_location , verbose = _DEBUG )
self . blocks = nn . Sequential ( * builder ( self . _in_chs , block_args ) )
self . feature_info = builder . features # builder provides info about feature channels for each block
self . _in_chs = builder . in_chs
@ -875,7 +875,7 @@ def spnasnet_100(pretrained=False, **kwargs):
@register_model
def efficientnet_b0 ( pretrained = False , * * kwargs ) :
""" EfficientNet-B0 """
# NOTE for train, drop_rate should be 0.2, drop_ connect _rate should be 0.2
# NOTE for train, drop_rate should be 0.2, drop_ path _rate should be 0.2
model = _gen_efficientnet (
' efficientnet_b0 ' , channel_multiplier = 1.0 , depth_multiplier = 1.0 , pretrained = pretrained , * * kwargs )
return model
@ -884,7 +884,7 @@ def efficientnet_b0(pretrained=False, **kwargs):
@register_model
def efficientnet_b1 ( pretrained = False , * * kwargs ) :
""" EfficientNet-B1 """
# NOTE for train, drop_rate should be 0.2, drop_ connect _rate should be 0.2
# NOTE for train, drop_rate should be 0.2, drop_ path _rate should be 0.2
model = _gen_efficientnet (
' efficientnet_b1 ' , channel_multiplier = 1.0 , depth_multiplier = 1.1 , pretrained = pretrained , * * kwargs )
return model
@ -893,7 +893,7 @@ def efficientnet_b1(pretrained=False, **kwargs):
@register_model
def efficientnet_b2 ( pretrained = False , * * kwargs ) :
""" EfficientNet-B2 """
# NOTE for train, drop_rate should be 0.3, drop_ connect _rate should be 0.2
# NOTE for train, drop_rate should be 0.3, drop_ path _rate should be 0.2
model = _gen_efficientnet (
' efficientnet_b2 ' , channel_multiplier = 1.1 , depth_multiplier = 1.2 , pretrained = pretrained , * * kwargs )
return model
@ -902,7 +902,7 @@ def efficientnet_b2(pretrained=False, **kwargs):
@register_model
def efficientnet_b2a ( pretrained = False , * * kwargs ) :
""" EfficientNet-B2 @ 288x288 w/ 1.0 test crop """
# NOTE for train, drop_rate should be 0.3, drop_ connect _rate should be 0.2
# NOTE for train, drop_rate should be 0.3, drop_ path _rate should be 0.2
model = _gen_efficientnet (
' efficientnet_b2a ' , channel_multiplier = 1.1 , depth_multiplier = 1.2 , pretrained = pretrained , * * kwargs )
return model
@ -911,7 +911,7 @@ def efficientnet_b2a(pretrained=False, **kwargs):
@register_model
def efficientnet_b3 ( pretrained = False , * * kwargs ) :
""" EfficientNet-B3 """
# NOTE for train, drop_rate should be 0.3, drop_ connect _rate should be 0.2
# NOTE for train, drop_rate should be 0.3, drop_ path _rate should be 0.2
model = _gen_efficientnet (
' efficientnet_b3 ' , channel_multiplier = 1.2 , depth_multiplier = 1.4 , pretrained = pretrained , * * kwargs )
return model
@ -920,7 +920,7 @@ def efficientnet_b3(pretrained=False, **kwargs):
@register_model
def efficientnet_b3a ( pretrained = False , * * kwargs ) :
""" EfficientNet-B3 @ 320x320 w/ 1.0 test crop-pct """
# NOTE for train, drop_rate should be 0.3, drop_ connect _rate should be 0.2
# NOTE for train, drop_rate should be 0.3, drop_ path _rate should be 0.2
model = _gen_efficientnet (
' efficientnet_b3a ' , channel_multiplier = 1.2 , depth_multiplier = 1.4 , pretrained = pretrained , * * kwargs )
return model
@ -929,7 +929,7 @@ def efficientnet_b3a(pretrained=False, **kwargs):
@register_model
def efficientnet_b4 ( pretrained = False , * * kwargs ) :
""" EfficientNet-B4 """
# NOTE for train, drop_rate should be 0.4, drop_ connect _rate should be 0.2
# NOTE for train, drop_rate should be 0.4, drop_ path _rate should be 0.2
model = _gen_efficientnet (
' efficientnet_b4 ' , channel_multiplier = 1.4 , depth_multiplier = 1.8 , pretrained = pretrained , * * kwargs )
return model
@ -938,7 +938,7 @@ def efficientnet_b4(pretrained=False, **kwargs):
@register_model
def efficientnet_b5 ( pretrained = False , * * kwargs ) :
""" EfficientNet-B5 """
# NOTE for train, drop_rate should be 0.4, drop_ connect _rate should be 0.2
# NOTE for train, drop_rate should be 0.4, drop_ path _rate should be 0.2
model = _gen_efficientnet (
' efficientnet_b5 ' , channel_multiplier = 1.6 , depth_multiplier = 2.2 , pretrained = pretrained , * * kwargs )
return model
@ -947,7 +947,7 @@ def efficientnet_b5(pretrained=False, **kwargs):
@register_model
def efficientnet_b6 ( pretrained = False , * * kwargs ) :
""" EfficientNet-B6 """
# NOTE for train, drop_rate should be 0.5, drop_ connect _rate should be 0.2
# NOTE for train, drop_rate should be 0.5, drop_ path _rate should be 0.2
model = _gen_efficientnet (
' efficientnet_b6 ' , channel_multiplier = 1.8 , depth_multiplier = 2.6 , pretrained = pretrained , * * kwargs )
return model
@ -956,7 +956,7 @@ def efficientnet_b6(pretrained=False, **kwargs):
@register_model
def efficientnet_b7 ( pretrained = False , * * kwargs ) :
""" EfficientNet-B7 """
# NOTE for train, drop_rate should be 0.5, drop_ connect _rate should be 0.2
# NOTE for train, drop_rate should be 0.5, drop_ path _rate should be 0.2
model = _gen_efficientnet (
' efficientnet_b7 ' , channel_multiplier = 2.0 , depth_multiplier = 3.1 , pretrained = pretrained , * * kwargs )
return model
@ -965,7 +965,7 @@ def efficientnet_b7(pretrained=False, **kwargs):
@register_model
def efficientnet_b8 ( pretrained = False , * * kwargs ) :
""" EfficientNet-B8 """
# NOTE for train, drop_rate should be 0.5, drop_ connect _rate should be 0.2
# NOTE for train, drop_rate should be 0.5, drop_ path _rate should be 0.2
model = _gen_efficientnet (
' efficientnet_b8 ' , channel_multiplier = 2.2 , depth_multiplier = 3.6 , pretrained = pretrained , * * kwargs )
return model
@ -974,7 +974,7 @@ def efficientnet_b8(pretrained=False, **kwargs):
@register_model
def efficientnet_l2 ( pretrained = False , * * kwargs ) :
""" EfficientNet-L2. """
# NOTE for train, drop_rate should be 0.5, drop_ connect _rate should be 0.2
# NOTE for train, drop_rate should be 0.5, drop_ path _rate should be 0.2
model = _gen_efficientnet (
' efficientnet_l2 ' , channel_multiplier = 4.3 , depth_multiplier = 5.3 , pretrained = pretrained , * * kwargs )
return model
@ -1007,7 +1007,7 @@ def efficientnet_el(pretrained=False, **kwargs):
@register_model
def efficientnet_cc_b0_4e ( pretrained = False , * * kwargs ) :
""" EfficientNet-CondConv-B0 w/ 8 Experts """
# NOTE for train, drop_rate should be 0.2, drop_ connect _rate should be 0.2
# NOTE for train, drop_rate should be 0.2, drop_ path _rate should be 0.2
model = _gen_efficientnet_condconv (
' efficientnet_cc_b0_4e ' , channel_multiplier = 1.0 , depth_multiplier = 1.0 , pretrained = pretrained , * * kwargs )
return model
@ -1016,7 +1016,7 @@ def efficientnet_cc_b0_4e(pretrained=False, **kwargs):
@register_model
def efficientnet_cc_b0_8e ( pretrained = False , * * kwargs ) :
""" EfficientNet-CondConv-B0 w/ 8 Experts """
# NOTE for train, drop_rate should be 0.2, drop_ connect _rate should be 0.2
# NOTE for train, drop_rate should be 0.2, drop_ path _rate should be 0.2
model = _gen_efficientnet_condconv (
' efficientnet_cc_b0_8e ' , channel_multiplier = 1.0 , depth_multiplier = 1.0 , experts_multiplier = 2 ,
pretrained = pretrained , * * kwargs )
@ -1025,7 +1025,7 @@ def efficientnet_cc_b0_8e(pretrained=False, **kwargs):
@register_model
def efficientnet_cc_b1_8e ( pretrained = False , * * kwargs ) :
""" EfficientNet-CondConv-B1 w/ 8 Experts """
# NOTE for train, drop_rate should be 0.2, drop_ connect _rate should be 0.2
# NOTE for train, drop_rate should be 0.2, drop_ path _rate should be 0.2
model = _gen_efficientnet_condconv (
' efficientnet_cc_b1_8e ' , channel_multiplier = 1.0 , depth_multiplier = 1.1 , experts_multiplier = 2 ,
pretrained = pretrained , * * kwargs )
@ -1355,7 +1355,7 @@ def tf_efficientnet_el(pretrained=False, **kwargs):
@register_model
def tf_efficientnet_cc_b0_4e ( pretrained = False , * * kwargs ) :
""" EfficientNet-CondConv-B0 w/ 4 Experts. Tensorflow compatible variant """
# NOTE for train, drop_rate should be 0.2, drop_ connect _rate should be 0.2
# NOTE for train, drop_rate should be 0.2, drop_ path _rate should be 0.2
kwargs [ ' bn_eps ' ] = BN_EPS_TF_DEFAULT
kwargs [ ' pad_type ' ] = ' same '
model = _gen_efficientnet_condconv (
@ -1366,7 +1366,7 @@ def tf_efficientnet_cc_b0_4e(pretrained=False, **kwargs):
@register_model
def tf_efficientnet_cc_b0_8e ( pretrained = False , * * kwargs ) :
""" EfficientNet-CondConv-B0 w/ 8 Experts. Tensorflow compatible variant """
# NOTE for train, drop_rate should be 0.2, drop_ connect _rate should be 0.2
# NOTE for train, drop_rate should be 0.2, drop_ path _rate should be 0.2
kwargs [ ' bn_eps ' ] = BN_EPS_TF_DEFAULT
kwargs [ ' pad_type ' ] = ' same '
model = _gen_efficientnet_condconv (
@ -1377,7 +1377,7 @@ def tf_efficientnet_cc_b0_8e(pretrained=False, **kwargs):
@register_model
def tf_efficientnet_cc_b1_8e ( pretrained = False , * * kwargs ) :
""" EfficientNet-CondConv-B1 w/ 8 Experts. Tensorflow compatible variant """
# NOTE for train, drop_rate should be 0.2, drop_ connect _rate should be 0.2
# NOTE for train, drop_rate should be 0.2, drop_ path _rate should be 0.2
kwargs [ ' bn_eps ' ] = BN_EPS_TF_DEFAULT
kwargs [ ' pad_type ' ] = ' same '
model = _gen_efficientnet_condconv (