aiaccel.hpo.apps package#

Subpackages#

Submodules#

aiaccel.hpo.apps.optimize module#

class aiaccel.hpo.apps.optimize.HparamsManager(**params_def: dict[str, int | float | str | list[int | float] | Suggest[T]])[source]#

Bases: object

Manages hyperparameters for optimization. This class allows defining hyperparameters with various types and provides a method to suggest hyperparameters for a given trial. .. attribute:: params

A dictionary where keys are hyperparameter names and values are callables that take a Trial object and return a hyperparameter value.

type:

dict

__init__(**params_def

dict[str, int | float | str | list[int | float] | Suggest[T]]) -> None: Initializes the HparamsManager with the given hyperparameter definitions.

suggest_hparams(trial

Trial) -> dict[str, float | int | str | list[float | int | str]]: Suggests hyperparameters for the given trial.

suggest_hparams(trial: Trial) dict[str, float | int | str | list[float | int | str]][source]#

Suggests hyperparameters for a given trial. This method generates a dictionary of hyperparameters by applying the parameter functions stored in self.params to the provided trial. :param trial: An Optuna trial object used to suggest hyperparameters. :type trial: Trial

Returns:

A dictionary where keys are parameter names and values are the suggested hyperparameters, which can be of type float, int, str, or a list of these types.

Return type:

dict[str, float | int | str | list[float | int | str]]

aiaccel.hpo.apps.optimize.main() None[source]#

Main function to execute the hyperparameter optimization process using a Dask cluster. This function parses command-line arguments, loads the configuration, sets up the Dask client, and runs the optimization trials in a distributed manner.

Command-line arguments:
  • –config (str, optional): Path to the configuration file.

  • –resume (bool, optional): Flag to resume from the previous study.

  • –resumable (bool, optional): Flag to make the study resumable by setting appropriate storage.

Usage:
  • Start a new study:

    python -m aiaccel.hpo.apps.optimize –config config.yaml

  • Resume from the previous study:

    python -m aiaccel.hpo.apps.optimize –config config.yaml –resume

  • Make the study resumable:

    python -m aiaccel.hpo.apps.optimize –config config.yaml –resumable

Config file (yaml) example:

~~~ yaml study:

_target_: optuna.create_study direction: minimize storage:

_target_: optuna.storages.InMemoryStorage

study_name: aiaccel_study load_if_exists: false

cluster:

_target_: distributed.Client n_workers: 4 threads_per_worker: 1

sampler:

_target_: optuna.samplers.TPESampler seed: 0

params:

_convert_: partial _target_: aiaccel.apps.optimize.HparamsManager x1: [0, 1] x2:

_target_: aiaccel.apps.optimize.SuggestFloat name: x2 low: 0.0 high: 1.0 log: false

n_trials: 30 n_max_jobs: 4 ~~~

Module contents#