siml.services.training package¶
Subpackages¶
Submodules¶
siml.services.training.data_loader_builder module¶
- class siml.services.training.data_loader_builder.DataLoaderBuilder(main_setting: MainSetting, collate_fn: CollateFunctionGenerator, decrypt_key: bytes | None = None)¶
Bases:
object
- create() tuple[torch.utils.data.dataloader.DataLoader, torch.utils.data.dataloader.DataLoader, torch.utils.data.dataloader.DataLoader] ¶
Create dataloaders
- Returns:
Train loader, validaition loader, test loader
- Return type:
tuple[DataLoader, DataLoader, DataLoader]
siml.services.training.engine_builder module¶
- class siml.services.training.engine_builder.EvaluatorEngineBuilder(env_setting: ModelEnvironmentSetting, prepare_batch_function: Callable, trainer_setting: TrainerSetting, loss_function: ILossCalculator, spliter: TensorSpliter)¶
Bases:
object
- class siml.services.training.engine_builder.TrainerEngineBuilder(env_setting: ModelEnvironmentSetting, prepare_batch_function: Callable, trainer_setting: TrainerSetting, debug_logger: TrainDataDebugLogger | None = None)¶
Bases:
object
- create_supervised_trainer(model: Network, optimizer: Optimizer, update_function: IStepUpdateFunction) Engine ¶
Create supervised trainer engine
- Parameters:
model (Network) – model object
optimizer (torch.optim.Optimizer) – optimizer
update_function (IStepUpdateFunction) – update function
- Returns:
Ignite trainer engine
- Return type:
Engine
siml.services.training.events_assigners module¶
- class siml.services.training.events_assigners.StopTriggerEvents(value)¶
Bases:
Enum
An enumeration.
- EVALUATED = 'evaluated'¶
- class siml.services.training.events_assigners.TrainerEventsAssigner(trainer_setting: TrainerSetting, file_logger: SimlTrainingFileLogger, console_logger: SimlTrainingConsoleLogger, train_loader: DataLoader, validation_loader: DataLoader, evaluator: Engine, model: Network, optimizer: Optimizer, timer: SimlStopWatch, debug_logger: TrainDataDebugLogger | None = None)¶
Bases:
object
- assign_handlers(trainer: Engine) None ¶
Assign handlers to trainer engine
- Parameters:
trainer (Engine) – trainer engine object
- fire_stop_trigger(engine)¶
- log_training_loss(engine: Engine)¶
- log_training_results(engine: Engine)¶
- class siml.services.training.events_assigners.ValidationEventsAssigner(file_logger: SimlTrainingFileLogger, console_logger: SimlTrainingConsoleLogger, log_trigger_epoch: int, train_loader: DataLoader, validation_loader: DataLoader, trainer: Engine, model: Network, trainer_setting: TrainerSetting, timer: SimlStopWatch)¶
Bases:
object
- assign_handlers(evaluator: Engine, optuna_trial: bool) None ¶
Assign handlers to evaluator engine
- Parameters:
evaluator (Engine) – evaluator engine
optuna_trial (bool) – If true, run optuna
- log_evaluation(engine)¶
- score_function(engine: Engine) float ¶
siml.services.training.inner_settings module¶
- class siml.services.training.inner_settings.InnerTrainingSetting(main_setting: siml.setting.MainSetting | Any)¶
Bases:
object
- property log_dataset_file_path¶
- property log_file_path¶
- property loss_figure_path¶
- main_setting: MainSetting | Any¶
- property trainer_setting: TrainerSetting¶
siml.services.training.metrics_builder module¶
- class siml.services.training.metrics_builder.LossDetailsMetrics(loss_calculator: ILossCalculator)¶
Bases:
Metric
- compute() dict[str, float] ¶
Computes the metric based on it’s accumulated state.
This is called at the end of each epoch.
- Returns:
the actual quantity of interest.
- Return type:
Any
- Raises:
NotComputableError – raised when the metric cannot be computed.
- reset()¶
Resets the metric to it’s initial state.
This is called at the start of each epoch.
- update(output)¶
Updates the metric’s state using the passed batch output.
This is called once for each batch.
- Parameters:
output – the is the output from the engine’s process function.
siml.services.training.tensor_spliter module¶
- class siml.services.training.tensor_spliter.TensorSpliter(input_time_series_keys: list[str], output_time_series_keys: list[str])¶
Bases:
object
siml.services.training.trainers_builder module¶
- class siml.services.training.trainers_builder.TrainersBuilder(trainer_setting: TrainerSetting, model_setting: ModelSetting, env_setting: ModelEnvironmentSetting, prepare_batch_function: Callable, loss_function: ILossCalculator, decrypt_key: bytes | None = None, debug_logger: TrainDataDebugLogger | None = None)¶
Bases:
object
- create(epoch_length: int | None = None) tuple[ignite.engine.engine.Engine, ignite.engine.engine.Engine, siml.networks.network.Network, torch.optim.optimizer.Optimizer] ¶
- create_engines(model: Network, optimizer: Optimizer) tuple[ignite.engine.engine.Engine, ignite.engine.engine.Engine] ¶
- create_model()¶
- class siml.services.training.trainers_builder.UpdateFunctionSelector(trainer_setting: TrainerSetting, env_setting: ModelEnvironmentSetting, loss_function: ILossCalculator, spliter: TensorSpliter)¶
Bases:
object
- select() IStepUpdateFunction ¶
siml.services.training.training_logger module¶
- class siml.services.training.training_logger.LogRecordItems(*, epoch: int, train_loss: float, validation_loss: float, train_other_losses: dict[str, float], validation_other_losses: dict[str, float], elapsed_time: float, train_loss_details: dict[str, float] | None = None, validation_loss_details: dict[str, float] | None = None)¶
Bases:
object
- class siml.services.training.training_logger.SimlTrainingConsoleLogger(display_margin: int, loss_keys: list[str], output_names: list[str])¶
Bases:
object
- get_header() str ¶
- output(log_record: LogRecordItems) str ¶
- output_header() None ¶
- class siml.services.training.training_logger.SimlTrainingFileLogger(file_path: Path, loss_figure_path: Path, loss_keys: list[str], output_names: list[str], continue_mode: bool = False)¶
Bases:
object
- read_history() DataFrame ¶
- read_offset_start_time() float ¶
- save_figure() None ¶
- save_model(epoch: int, model: Network, optimizer: Optimizer, validation_loss: float, trainer_setting: TrainerSetting) None ¶
- write(log_record: LogRecordItems) None ¶
- write_header_if_needed() None ¶