Add a task
A task supplies the target specification, compiles the model, owns fit inputs and callbacks, and evaluates predictions.
- Add a
TaskABCsubclass undersrc/crest/tasks/. Accept the keyword argumentscheckpoint_pathandearly_stopping_patiencethatinstantiate_task_componentpasses to the constructor. - Validate
task.paramsand derive aTargetSpecfrom the dataset bundle. Ensure its ordered output names and shapes match the tensors the model family builds and the targets passed to Keras. - Implement
compile_modelandbuild_fit_plan. Put inputs, targets, and any validation data inFitPlan.fit_kwargsand task callbacks inFitPlan.callbacks. The runner supplies scheduling arguments such as epochs and batch size. - Implement
evaluateandevaluate_predictions. Declare the task metrics used innas.score,nas.prune, andnas.feasibilityinmetric_contract. Use the same names in returned metrics and policies. - Return a stable key from
name. Register the class withtask_registryinbuiltin_components.pyand select the key undertask.name. Set task-specific options undertask.params.
For a worked example, SoundClassificationTask validates UrbanSound8K class metadata and declares a single class_logits output with one value per class. It compiles with sparse categorical cross-entropy configured for logits and declares loss, accuracy, and macro_f1 for evaluation. The odometry task in odometry_regression.py shows the two-output case.
Check target specifications and fit plans in both search and final training modes. Pass small, known predictions to evaluate_predictions to test metric names and values without training a model. See test_sound_classification_task.py.
For more information, read the full task README on GitHub.