arlbench.utils

arlbench.utils.config_space_to_gymnasium_space(config_space, seed=None)[source]

Converts a configuration space to a gymnasium space.

Parameters:
  • config_space (ConfigurationSpace) – Configuration space.

  • seed (int | None, optional) – Seed for the gymnasium space. Defaults to None.

Returns:

Gymnasium space.

Return type:

gymnasium.spaces.Dict

arlbench.utils.config_space_to_yaml(config_space, config_key='hp_config', seed=0)[source]

Converts a ConfigSpace object to yaml.

Parameters:
  • config_space (ConfigurationSpace) – Configuration space object.

  • config_key (str, optional) – Key for the hyperparameters.

  • "hp_config". (Defaults to)

  • seed (int, optional) – Configuration space seed to write to yaml. Defaults to 0.

Returns:

_description_

Return type:

_type_

arlbench.utils.gymnasium_space_to_gymnax_space(space)[source]

Converst a gymnasium space to a gymnax space.

Parameters:

space (Space) – Gymnasium space.

Returns:

Gymnax space.

Return type:

gymnax_spaces.Space

arlbench.utils.recursive_concat(dict1, dict2, axis=0)[source]

Recursively concatenates two dictionaries value-wise for same keys.

Parameters:
  • dict1 (dict) – First dictionary.

  • dict2 (dict) – Second dictionary.

  • axis (int, optional) – Concat axis. Defaults to 0.

Returns:

Concatenated dictionary.

Return type:

dict

arlbench.utils.save_defaults_to_yaml(hp_config_space, nas_config_sapce, algorithm)[source]

Extracts the default values of the hp_config_space and nas_config_sapce and returns a yaml file.

Parameters:
  • hp_config_space (ConfigurationSpace) – The hyperparameter configuration space

  • algorithm. (space of the)

  • nas_config_sapce (ConfigurationSpace) – The neural architecture configuration

  • algorithm.

  • algorithm (str) – The name of the algorithm.

Returns:

yaml string.

Return type:

str

arlbench.utils.tuple_concat(tuple1, tuple2, axis=0)[source]

Concatenates two tuples element-wise.

Parameters:
  • tuple1 (tuple) – First tuple.

  • tuple2 (tuple) – Second tuple.

  • axis (int, optional) – Concat axis. Defaults to 0.

Returns:

Concatenated tuple.

Return type:

tuple

Modules

common

Common utility functions for the ARLBench package.