mlrl.testbed.modes.mode_batch module¶
Author: Michael Rapp (michael.rapp.ml@gmail.com)
Provides classes that implement a mode of operation for performing multiple experiments.
- class mlrl.testbed.modes.mode_batch.BatchMode(config_file_factory: Callable[[str], ConfigFile] | None = None)¶
Bases:
ModeAn abstract base class for all modes of operation that perform multiple experiments.
- ARGUMENT_RUNNER = '--runner'¶
- CONFIG_FILE = <mlrl.util.cli.PathArgument object>¶
- class ConfigFile(file_path: Path, schema_file_path: Path)¶
Bases:
ABCA YAML configuration file that configures the batch of experiments to be run.
- class DefaultArgument(name: str, value: str)¶
Bases:
objectA default parameter defined in the configuration file.
- Attributes:
name: The name of the parameter value: The value of the parameter
- Factory¶
alias of
Callable[[str],BatchMode.ConfigFile]
- class Parameter(name: str, values: list[ParameterValue])¶
Bases:
objectA parameter defined in the configuration file.
- Attributes:
name: The name of the parameter values: One or several values that should be set for the parameter
- values: list[ParameterValue]¶
- class ParameterValue(value: str, additional_arguments: list[str] = <factory>)¶
Bases:
objectA value that should be set for a parameter.
- Attributes:
value: The value to be set additional_arguments: Additional arguments associated with the parameter
- abstract property dataset_args: list[ArgumentList]¶
A list that contains the command line arguments corresponding to the datasets to be used in the different experiments defined in the configuration file.
- property default_arguments: list[DefaultArgument]¶
A list that contains all default arguments defined in the configuration file.
- property parameter_args: list[ArgumentList]¶
A list that contains the command line arguments corresponding to the algorithmic parameters to be used in the different experiments defined in the configuration file.
- LIST_COMMANDS = <mlrl.util.cli.FlagArgument object>¶
- class LogRunner¶
Bases:
RunnerAllows to log the commands of experiments, instead of executing them.
- run_batch(args: Namespace, batch: list[Command], recipe: Recipe)¶
Must be implemented by subclasses in order to run all commands in a given batch.
- Parameters:
args – The command line arguments specified by the user
batch – The batch of experiments to be run
recipe – A Recipe that provides access to the ingredients that are needed for setting up experiments
- class Runner(name: str)¶
Bases:
ABCAn abstract base class for all classes that allow to run experiments.
- abstractmethod run_batch(args: Namespace, batch: list[Command], recipe: Recipe)¶
Must be implemented by subclasses in order to run all commands in a given batch.
- Parameters:
args – The command line arguments specified by the user
batch – The batch of experiments to be run
recipe – A Recipe that provides access to the ingredients that are needed for setting up experiments
- SEPARATE_FOLDS = <mlrl.util.cli.BoolArgument object>¶
- class SequentialRunner¶
Bases:
RunnerAllows to run experiments sequentially.
- run_batch(args: Namespace, batch: list[Command], recipe: Recipe)¶
Must be implemented by subclasses in order to run all commands in a given batch.
- Parameters:
args – The command line arguments specified by the user
batch – The batch of experiments to be run
recipe – A Recipe that provides access to the ingredients that are needed for setting up experiments
- add_runner(runner: Runner) BatchMode¶
Adds a runner that may be used in batch mode for running individual experiments in a batch.
- Parameters:
runner – The runner to be added
- Returns:
The batch mode itself
- configure_algorithmic_arguments(cli: CommandLineInterface, algorithmic_arguments: list[Argument])¶
Must be implemented by subclasses in order to configure the command line interface according to the mode of operation.
- Parameters:
cli – The command line interface to be configured
algorithmic_arguments – The arguments that should be added to the command line interface for configuring the algorithm’s hyperparameters
- configure_control_arguments(cli: CommandLineInterface, control_arguments: list[Argument])¶
Must be implemented by subclasses in order to configure the command line interface according to the mode of operation.
- Parameters:
cli – The command line interface to be configured
control_arguments – The arguments that should be added to the command line interface for controlling mlrl-testbed’s behavior
- run_experiment(control_arguments: set[Argument], algorithmic_arguments: set[Argument], args: Namespace, recipe: Recipe)¶
Must be implemented by subclasses in order to run an experiment according to the command line arguments specified by the user.
- Parameters:
control_arguments – The arguments that should be added to the command line interface for controlling mlrl-testbed’s behavior
algorithmic_arguments – The arguments that should be added to the command line interface for configuring the algorithm’s hyperparameters
args – The command line arguments specified by the user
recipe – A Recipe that provides access to the ingredients that are needed for setting up experiments
- property runners: list[Runner]¶
The runners that may be used for running individual experiments in a batch.
- to_enum() ExperimentMode¶
Returns the ExperimentMode that corresponds to this mode of operation.
- Returns:
An ExperimentMode