MobileNetV3Backbone
classkeras_cv.models.MobileNetV3Backbone(
stackwise_expansion,
stackwise_filters,
stackwise_kernel_size,
stackwise_stride,
stackwise_se_ratio,
stackwise_activation,
include_rescaling,
input_shape=(None, None, 3),
input_tensor=None,
alpha=1.0,
**kwargs
)
Instantiates the MobileNetV3 architecture.
References
For transfer learning use cases, make sure to read the guide to transfer learning & fine-tuning.
Arguments
Rescaling(scale=1 / 255)
layer.layers.Input()
)
to use as image input for the model.alpha
< 1.0, proportionally decreases the number
of filters in each layer.alpha
> 1.0, proportionally increases the number
of filters in each layer.alpha
= 1, default number of filters from the paper
are used at each layer.Example
input_data = tf.ones(shape=(8, 224, 224, 3))
# Randomly initialized backbone with a custom config
model = MobileNetV3Backbone(
stackwise_expansion=[1, 72.0 / 16, 88.0 / 24, 4, 6, 6, 3, 3, 6, 6, 6],
stackwise_filters=[16, 24, 24, 40, 40, 40, 48, 48, 96, 96, 96],
stackwise_kernel_size=[3, 3, 3, 5, 5, 5, 5, 5, 5, 5, 5],
stackwise_stride=[2, 2, 1, 2, 1, 1, 1, 1, 2, 1, 1],
stackwise_se_ratio=[0.25, None, None, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25],
stackwise_activation=["relu", "relu", "relu", "hard_swish", "hard_swish", "hard_swish", "hard_swish", "hard_swish", "hard_swish", "hard_swish", "hard_swish"],
include_rescaling=False,
)
output = model(input_data)
from_preset
methodMobileNetV3Backbone.from_preset()
Instantiate MobileNetV3Backbone model from preset config and weights.
Arguments
None
, which follows whether the preset has
pretrained weights available.Examples
# Load architecture and weights from preset
model = keras_cv.models.MobileNetV3Backbone.from_preset(
"mobilenet_v3_large_imagenet",
)
# Load randomly initialized model from preset architecture with weights
model = keras_cv.models.MobileNetV3Backbone.from_preset(
"mobilenet_v3_large_imagenet",
load_weights=False,
Preset name | Parameters | Description |
---|---|---|
mobilenet_v3_small | 933.50K | MobileNetV3 model with 14 layers where the batch normalization and hard-swish activation are applied after the convolution layers. |
mobilenet_v3_large | 2.99M | MobileNetV3 model with 28 layers where the batch normalization and hard-swish activation are applied after the convolution layers. |
mobilenet_v3_large_imagenet | 2.99M | MobileNetV3 model with 28 layers where the batch normalization and hard-swish activation are applied after the convolution layers. Pre-trained on the ImageNet 2012 classification task. |
mobilenet_v3_small_imagenet | 933.50K | MobileNetV3 model with 14 layers where the batch normalization and hard-swish activation are applied after the convolution layers. Pre-trained on the ImageNet 2012 classification task. |
MobileNetV3SmallBackbone
classkeras_cv.models.MobileNetV3SmallBackbone(
stackwise_expansion,
stackwise_filters,
stackwise_kernel_size,
stackwise_stride,
stackwise_se_ratio,
stackwise_activation,
include_rescaling,
input_shape=(None, None, 3),
input_tensor=None,
alpha=1.0,
**kwargs
)
MobileNetV3Backbone model with 14 layers.
References
For transfer learning use cases, make sure to read the guide to transfer learning & fine-tuning.
Arguments
Rescaling(scale=1 / 255)
layer. Defaults to True.layers.Input()
)
to use as image input for the model.Example
input_data = tf.ones(shape=(8, 224, 224, 3))
# Randomly initialized backbone
model = MobileNetV3SmallBackbone()
output = model(input_data)
MobileNetV3LargeBackbone
classkeras_cv.models.MobileNetV3LargeBackbone(
stackwise_expansion,
stackwise_filters,
stackwise_kernel_size,
stackwise_stride,
stackwise_se_ratio,
stackwise_activation,
include_rescaling,
input_shape=(None, None, 3),
input_tensor=None,
alpha=1.0,
**kwargs
)
MobileNetV3Backbone model with 28 layers.
References
For transfer learning use cases, make sure to read the guide to transfer learning & fine-tuning.
Arguments
Rescaling(scale=1 / 255)
layer. Defaults to True.layers.Input()
)
to use as image input for the model.Example
input_data = tf.ones(shape=(8, 224, 224, 3))
# Randomly initialized backbone
model = MobileNetV3LargeBackbone()
output = model(input_data)