The model spec: one serializable identity per architecture, and the single builder; importable without Keras.
A ModelSpec is the typed Params of one family (selected by its family field) and the input shape
without the batch axis. build(spec) builds it. Families are a closed set: each has a Keras-free
<family>_params.py and a build(params, input_shape, *, batch_size=None, name=None) in its model module.
Machine-readable model
ModelParamsattribute The Params of any family, discriminated by family. FIXED_INPUTconstant Families whose input shape follows from their Params (params.inputshape); their inputshape may be None. ModelSpecclass The serializable identity of an architecture. buildfunction Build the model a spec describes.
ModelParams = Annotated[ComposerParams | ConformerParams | ConvMixerParams | CorNetParams | EfficientNetParams | FastEnhancerParams | MetaFormerParams | MiniResNetV1Params | MlperfTinyParams | MobileNetV1Params | MobileOneParams | RegNetParams | ResNetParams | SileroVadParams | TcnParams | TimePPGParams | TsMixerParams | UNetParams | UNextParams, Field( discriminator = 'family' )]
The Params of any family, discriminated by family.
FIXED_INPUT = (FastEnhancerParams, MlperfTinyParams, SileroVadParams)
Families whose input shape follows from their Params (params.input_shape); their input_shape may be None.
The serializable identity of an architecture.
model_config = ConfigDict( frozen = True , extra = 'forbid' )
The family’s typed Params; params.family selects the family.
input_shape: tuple[ int | None , ... ] | None = None
Input shape without the batch axis; None for a variable
axis. None for the families in FIXED_INPUT, whose shape follows from their Params.
build(spec: ModelSpec, * , batch_size: int | None = None , name: str | None = None ) -> keras.Model
Build the model a spec describes.
Parameters
Parameters of build Name Type Default Description specModelSpecRequired Family Params and input shape. batch_sizeint | NoneNone Static batch size; None for a dynamic batch. namestr | NoneNone Model name; the family when None. Give distinct names to combine two models
of one family in a Keras graph.
Returns
Returns of build Type Description keras.Modelkeras.Model: The model.