sad.task.training package
Submodules
sad.task.training.training module
- class TrainingTask(config: Dict, input_dir: Optional[str] = None, output_dir: Optional[str] = None)[source]
Bases:
sad.task.base.TaskBase
A concrete task class that will be responsible to train a model.
This class inherits all existing properties in
sed.task.base.TaskBase
.- create_generator(model: sad.model.base.ModelBase) sad.generator.base.GeneratorBase [source]
Instance method to create a generator for training.
- Parameters
model (
sad.model.ModelBase
) – An instance of model that will be associated with the generator.- Returns
An instance of generator class that will be used to train the model in a trainer, an instance of
sad.trainer.TrainerBase
.- Return type
sad.generator.GeneratorBase
- Raises
RuntimeError – When a generator instance is not able to create from configuration in
self.generator_config
.
- create_model() sad.model.base.ModelBase [source]
Instance method to initialize a model for training.
- Returns
An instance of model class that will be trained in current task.
- Return type
sad.model.ModelBase
- Raises
RuntimeError – When a model instance is not able to initialize from configuration in
self.model_config
.
- create_trainer(model: sad.model.base.ModelBase, generator: sad.generator.base.GeneratorBase) sad.trainer.base.TrainerBase [source]
Instance method to create a trainer for training. Require an instance of
sad.model.ModelBase
and asad.generator.GeneratorBase
.- Parameters
model (
sad.model.ModelBase
) – An instance of model that will be associated with the trainer.generator (
sad.generator.GeneratorBase
) – An instance of generator that will be used by trainer.
- Returns
An instance of trainer class that will be used in current task.
- Return type
sad.trainer.TrainerBase
- Raises
RuntimeError – When a trainer instance is not able to initialize from configuration in
self.trainer_config
.
- property filename: str
A relative path pointing to where user-item interaction data are located. The path is relative to
self.input_dir
.
- property generator_config: Dict
A dictionary read from configuration of the task. It specifies the configuration to initialize a generator of type
sad.generator.GeneratorBase
. Will read directly from"generator"
field fromself.config
.An example is shown below:
name: ImplicitFeedbackGenerator spec: u_batch: 50 i_batch: 100
- property model_config: Dict
A dictionary read from configuration of the task. It specifies the configuration to initialize a model of type
sad.model.ModelBase
. Will read directly from"model"
field fromself.config
.An example is shown below:
name: SADModel spec: n: 200 m: 500 k: 100
- property model_id: str
A string that uniquely identifies a trained model. It is usually set to
"model_{self.task_id}"
.
- property trainer_config: Dict
A dictionary read from configuration of the task. It specifies the configuration to initialize a trainer of type
sad.trainer.TrainerBase
. Will read directly from"trainer"
field fromself.config
.An example is shown below:
name: SGDTrainer spec: n_iters: 50 u_idxs: [0, 1, 2, 3, 4, 5] w_l1: 0.01 w_l2: 0.01 callbacks: - name: "MetricsLoggingCallback" spec: every_iter: 1 every_step: 2
- run_task(config_file: Optional[str] = None)[source]
Main function that will be called when running a processing task.
- Parameters
config_file (
str
) – Ayml
file that contains configurations for running the processing task. Optional, whenNone
a default file at./ppgflow/tasks/processing/config.yml
will be used.