Skip to content
heliaEDGE
Reference
HELIA

mobileone

MobileOne is a fully convolutional neural network designed to have minimal latency when running in mobile/edge devices. The architecture consists of a series of depthwise separable convolutions and squeeze and excitation (SE) blocks. The network also uses standard batch normalization and ReLU activations that can be easily fused into the convolutional layers. Lastly, the network uses over-parameterized branches to improve training, yet can be merged into a single branch during inference.

For more info, refer to the original paper MobileOne: An Improved One millisecond Mobile Backbone.

Parameters are in helia_edge.models.mobileone_params.

Functions

Name Description
build MobileOne model from MobileOneParams
mobileone_block MobileOne block
mobileone_layer MobileOne layer

The MobileOne architecture has been modified to allow the following:

  • Enable 1D and 2D variants.
  • Enable dilated convolutions.
from helia_edge.models import MobileOneBlockParams, MobileOneParams, ModelSpec, build
params = MobileOneParams(
input_filters=24,
input_kernel_size=(1, 7),
input_strides=(1, 2),
input_padding=(0, 3),
blocks=[
MobileOneBlockParams(
filters=32, depth=2, kernel_size=(1, 7), strides=(1, 2), padding=(0, 3), se_ratio=2, num_conv_branches=2
)
],
include_top=True,
num_classes=5,
)
model = build(ModelSpec(params=params, input_shape=(1, 800, 1)))
model.summary()

Machine-readable model

function

MBConv block w/ expansion and SE

helia_edge/models/mobileone.py:58

mobileone_block(
output_filters: int,
kernel_size: int | tuple[int, int] = 3,
strides: int | tuple[int, int] = 1,
padding: int | tuple[int, int] = 0,
groups: int = 1,
dilation: int = 1,
inference_mode: bool = False,
se_ratio: int = 0,
num_conv_branches: int = 1,
activation: str = 'relu6',
name: str | None = None,
) -> keras.Layer

MBConv block w/ expansion and SE

Parameters of mobileone_block
NameTypeDefaultDescription
output_filtersintRequiredNumber of output filter channels
kernel_sizeint | tuple[int, int]3Kernel size. Defaults to 3.
stridesint | tuple[int, int]1Stride length. Defaults to 1.
se_ratiofloat0SE ratio. Defaults to 8.
namestr | NoneNoneBlock name. Defaults to None.
Returns of mobileone_block
TypeDescription
keras.Layerkeras.Layer: Functional layer
function

Create MobileOne TF functional model

helia_edge/models/mobileone.py:199

mobileone_layer(x: keras.KerasTensor, params: MobileOneParams, inference_mode: bool = False) -> keras.KerasTensor

Create MobileOne TF functional model

Parameters of mobileone_layer
NameTypeDefaultDescription
xkeras.KerasTensorRequiredInput tensor
paramsMobileOneParamsRequiredModel parameters.
Returns of mobileone_layer
TypeDescription
keras.KerasTensorkeras.KerasTensor: Output tensor
function

build

Python

Build a MobileOne model.

helia_edge/models/mobileone.py:274

build(
params: MobileOneParams,
input_shape: tuple[int | None, ...],
*,
batch_size: int | None = None,
name: str | None = None,
) -> keras.Model

Build a MobileOne model.

Parameters of build
NameTypeDefaultDescription
paramsMobileOneParamsRequiredModel parameters.
input_shapetuple[int | None, ...]RequiredInput shape without the batch axis; None for a variable axis.
batch_sizeint | NoneNoneStatic batch size; None for a dynamic batch.
namestr | NoneNoneModel name; the family when None.
Returns of build
TypeDescription
keras.Modelkeras.Model: The model, named ``mobileone`` unless ``name`` is given.