Trainers Module¶
The trainers module provides training utilities and callback management.
- class xflow.trainers.BaseTrainer(model: Any, data_pipeline: Any, output_dir: str, *, callbacks: List[Callback] | None = None, model_io: ModelIO | None = None, config: Dict[str, Any] | None = None)[source]¶
Bases:
ABCThin orchestrator: runs loops, dispatches callbacks, collects history. Creation/compilation of model/optimizer is outside; inject everything in.
- __init__(model: Any, data_pipeline: Any, output_dir: str, *, callbacks: List[Callback] | None = None, model_io: ModelIO | None = None, config: Dict[str, Any] | None = None)[source]¶
- class xflow.trainers.CallbackRegistry[source]¶
Bases:
objectRegistry for callback handlers or factories.
- xflow.trainers.build_callbacks_from_config(config: List[Dict[str, Any]], framework: str, name_key: str = 'name', params_key: str = 'params') List[Any][source]¶
Build a list of callbacks (native or unified) from a config list.
- Parameters:
config – List of callback config dicts. Each dict should have at least a ‘name’ key and optionally a ‘params’ dict.
framework – Which framework to use (‘tf’, ‘pl’, or ‘torch’).
name_key – Key in each config dict for the callback/factory name (default: ‘name’).
params_key – Key in each config dict for the callback/factory parameters (default: ‘params’).
- Returns:
List of instantiated callback objects.
Each config entry may either: 1) Define only ‘name’ + ‘params’ → handler must return a Callback instance (native/factory style) 2) Define ‘events’ (list of {event, name, params}) → use unified wrapper for event-based callbacks