mt.tf.keras_applications.mobilenet_v3_split

MobileNet v3 models split into 5 submodels.

The MobileNetV3 model is split into 5 parts:

  • The input parser block that downsamples once (MobileNetV3Parser()).

  • Block 0 to 3 that downample once for each block (MobileNetV3LargeBlock() or MobileNetV3SmallBlock()). As of 2023/05/15, there’s a possibility to have block 4 for MobileNetV3Large.

  • The mixer block that turns the downsampled grid into a (1,1,feat_dim) batch (MobileNetV3Mixer()).

  • Optionally the output block that may or may not contain the clasification head (MobileNetV3Output()).

Input arguments follow those of MobileNetV3. One can also use MobileNetV3Split() to create a model of submodels that is theoretically equivalent to the original MobileNetV3 model. However, no pre-trained weights exist.

Functions

mt.tf.keras_applications.mobilenet_v3_split.MobileNetV3Input(input_shape=None)

Prepares a MobileNetV3 input layer.

mt.tf.keras_applications.mobilenet_v3_split.MobileNetV3Parser(img_input, model_type: str = 'Large', minimalistic=False)

Prepares a MobileNetV3 parser block.

mt.tf.keras_applications.mobilenet_v3_split.MobileNetV3Mixer(input_tensor, params: MobileNetV3MixerParams, last_point_ch, alpha=1.0, model_type: str = 'Large', minimalistic=False)

Prepares a MobileNetV3 mixer block.

mt.tf.keras_applications.mobilenet_v3_split.MobileNetV3Output(input_tensor, model_type: str = 'Large', include_top=True, classes=1000, pooling=None, dropout_rate=0.2, classifier_activation='softmax')

Prepares a MobileNetV3 output block.

mt.tf.keras_applications.mobilenet_v3_split.MobileNetV3Split(input_shape=None, alpha: float = 1.0, model_type: str = 'Large', max_n_blocks: int = 6, minimalistic: bool = False, mixer_params: MobileNetV3MixerParams | None = None, include_top: bool = True, pooling=None, classes: int = 1000, dropout_rate: float = 0.2, classifier_activation='softmax', output_all: bool = False, name: str | None = None)

Prepares a model of submodels which is equivalent to a MobileNetV3 model.

Parameters:
  • input_shape (tuple) – Optional shape tuple, to be specified if you would like to use a model with an input image resolution that is not (224, 224, 3). It should have exactly 3 inputs channels (224, 224, 3). You can also omit this option if you would like to infer input_shape from an input_tensor. If you choose to include both input_tensor and input_shape then input_shape will be used if they match, if the shapes do not match then we will throw an error. E.g. (160, 160, 3) would be one valid value.

  • alpha (float) –

    controls the width of the network. This is known as the depth multiplier in the MobileNetV3 paper, but the name is kept for consistency with MobileNetV1 in Keras. - If alpha < 1.0, proportionally decreases the number

    of filters in each layer.

    • If alpha > 1.0, proportionally increases the number

      of filters in each layer.

    • If alpha = 1, default number of filters from the paper

      are used at each layer.

      the mobilenetv3 alpha value

  • model_type ({'Small', 'Large'}) – whether it is the small variant or the large variant

  • max_n_blocks (int) – the maximum number of blocks in the backbone. It is further constrained by the actual maximum number of blocks that the variant can implement.

  • minimalistic (bool) – In addition to large and small models this module also contains so-called minimalistic models, these models have the same per-layer dimensions characteristic as MobilenetV3 however, they do not utilize any of the advanced blocks (squeeze-and-excite units, hard-swish, and 5x5 convolutions). While these models are less efficient on CPU, they are much more performant on GPU/DSP.

  • mixer_params (mt.tfc.MobileNetV3MixerParams, optional) – parameters for defining the mixer block

  • include_top (bool, default True) – whether to include the fully-connected layer at the top of the network. Only valid if mixer_params is not null.

  • pooling (str, optional) –

    Optional pooling mode for feature extraction when include_top is False and mixer_params is not null. - None means that the output of the model will be the 4D tensor output of the last

    convolutional block.

    • avg means that global average pooling will be applied to the output of the last convolutional block, and thus the output of the model will be a 2D tensor.

    • max means that global max pooling will be applied.

  • classes (int, optional) – Optional number of classes to classify images into, only to be specified if mixer_params is not null and include_top is True.

  • dropout_rate (float) – fraction of the input units to drop on the last layer. Only to be specified if mixer_params is not null and include_top is True.

  • classifier_activation (object) – A str or callable. The activation function to use on the “top” layer. Ignored unless mixer_params is not null and include_top is True. Set classifier_activation=None to return the logits of the “top” layer. When loading pretrained weights, classifier_activation can only be None or “softmax”.

  • output_all (bool) – If True, the model returns the output tensor of every submodel other than the input layer. Otherwise, it returns the output tensor of the last submodel.

  • name (str, optional) – model name, if any. Default to ‘MobileNetV3LargeSplit’ or ‘MobileNetV3SmallSplit’.

Returns:

the output MobileNetV3 model split into 5 submodels

Return type:

tensorflow.keras.Model