Add a model family
A model family converts a trial's architecture parameters and a ModelBuildContext into a Keras model. The context supplies the dataset's input shape and dtype and the task's target specification.
- Create a
ModelFamilyABCsubclass undersrc/crest/model_families/. Implementsample_hparams(trial, ctx, config)andbuild_model(hparams, ctx, config). Return an uncompiled model for the task to compile. - Validate family settings with
validate_configand sampled or replayed choices withvalidate_hparams. Usedecode_trial_hparamsif saved values need rebuilding. For explicit proposers, implementtrial_search_space(ctx, config)with the same names, bounds, and choices thatsample_hparamsuses. - Check the export path. The base class can build an untrained model or load a trained checkpoint. Override
materialize_export_modelfor family-specific transformations and supplycustom_objects()if checkpoints use custom Keras types. - Register the family with
model_family_registryinbuiltin_components.py. Select it undermodel.family, set the export variant inmodel.params.export_variant, and put search overrides inmodel.search.
For example, both the Portenta and STM32 audio studies select the DS-CNN family and export a model with untrained weights. Each study configures its board separately.
model:
family: audio_dscnn
params:
export_variant: untrained
search: {}
See audio DS-CNN for categorical search overrides and odometry TCN for a custom export transformation. Test sampling and output shape with a small context, then try the export on the intended backend. The DS-CNN tests and TCN tests show both families in use.
For more information, read the full model-family README on GitHub.