data
MobileNetV4Config
extends
ModelConfigMobileNetV4Config(num_classes: int = 1000, in_channels: int = 3, variant: str = 'conv_small', dropout: float = 0.3, drop_path_rate: float = 0.0)Frozen configuration for every MobileNet-v4 variant.
One dataclass describes the whole family; variant selects which of
the paper's five searched architectures (Appendix D, Tables 11-15) is
built, and the remaining fields cover the classifier and regularisation
knobs that are not part of the searched topology.
Parameters
num_classesint= 1000Output classes of the classification head.
in_channelsint= 3Channels of the input image.
variantstr= "conv_small"Which searched architecture to build — one of
"conv_small",
"conv_medium", "conv_large", "hybrid_medium" or
"hybrid_large". The variant fixes the block sequence, the
stem width (24 for the Large models, 32 otherwise), the activation
(GELU for Hybrid-Large, ReLU for the rest) and whether residual
branches carry a layer scale (hybrids only).dropoutfloat= 0.3Dropout probability before the final
Linear. The paper trains
Conv-Small with 0.3 and every other variant with 0.2 (Table 10);
the factories set the matching value.drop_path_ratefloat= 0.0Peak stochastic-depth rate. Block
i of n drops its
residual branch with probability drop_path_rate * i / n. The
paper's recipe peaks at 0 (Conv-Small), 0.075 (Medium) and 0.35
(Large) during training (Table 10); the default leaves it off so
the model behaves deterministically unless a recipe asks for it.Attributes
model_typestrRegistry id,
"mobilenet_v4".Raises
ValueErrorIf
variant is not one of the five paper variants, or a rate
lies outside .Notes
Block sequences follow the authors' released implementation, which is what the published checkpoints were trained against. The four other variants match Tables 11, 12, 14 and 15 block for block. For Hybrid-Medium the released model orders several UIB blocks differently from Table 13 and carries one extra block in the stride-32 stage; its parameter count (10.56 M in units of ) is the 10.5 M that Table 6 reports.
Examples
>>> from lucid.models.vision.mobilenet_v4 import MobileNetV4Config
>>> cfg = MobileNetV4Config()
>>> cfg.model_type
'mobilenet_v4'
>>> cfg.variant, cfg.num_classes
('conv_small', 1000)
>>> MobileNetV4Config(variant="hybrid_large").variant
'hybrid_large'