Configs

Here is a tutorial on Google Colab that shows how to use the configs module

class labml.configs.BaseConfigs(*, _primary: str | None = None)[source]

You should subclass this class to create your own configurations

labml.configs.option(name: any | List[any])[source]
labml.configs.option(name: any | List[any], option_name: str)
labml.configs.option(name: any | List[any], pass_params: List[any])
labml.configs.option(name: any | List[any], option_name: str, pass_params: List[any])

Use this as a decorator to register configuration options.

This has multiple overloads

labml.configs.option(config_item: any | List[any])[source]
labml.configs.option(config_item: any | List[any], option_name: str)[source]
labml.configs.option(config_item: any | List[any], pass_params: List[any])[source]
labml.configs.option(config_item: any | List[any], option_name: str, pass_params: List[any])[source]
Parameters:
  • name – the configuration item or a list of items. If it is a list of items the function should return tuple.

  • option_name (str, optional) – name of the option. If not provided it will be derived from the function name.

  • pass_params (list, optional) – list of params to be passed. If not provided the configs object is passed. If provided the corresponding calculated configuration items will be passed to the function

labml.configs.calculate(name: any | List[any], func: Callable)[source]
labml.configs.calculate(name: any | List[any], option_name: str, func: Callable)
labml.configs.calculate(name: any | List[any], pass_params: List[any], func: Callable)
labml.configs.calculate(name: any | List[any], option_name: str, pass_params: List[any], func: Callable)

Use this to register configuration options.

This has multiple overloads

labml.configs.calculate(name: any | List[any], func: Callable)[source]
labml.configs.calculate(name: any | List[any], option_name: str, func: Callable)[source]
labml.configs.calculate(name: any | List[any], pass_params: List[any], func: Callable)[source]
labml.configs.calculate(name: any | List[any], option_name: str, pass_params: List[any], func: Callable)[source]
Parameters:
  • name – the configuration item or a list of items. If it is a list of items the function should return tuple.

  • func – the function to calculate the configuration

  • option_name (str, optional) – name of the option. If not provided it will be derived from the function name.

  • pass_params (list, optional) – list of params to be passed. If not provided the configs object is passed. If provided the corresponding calculated configuration items will be passed to the function

labml.configs.hyperparams(*args: any, is_hyperparam=True)[source]

Identifies configuration as (or not) hyper-parameters

Parameters:
  • *args – list of configurations

  • is_hyperparam (bool, optional) – whether the provided configuration items are hyper-parameters. Defaults to True.

labml.configs.meta_config(*args: any, is_meta=True)[source]

Identifies configuration as meta parameter

Parameters:
  • *args – list of configurations

  • is_meta (bool, optional) – whether the provided configuration items are meta. Defaults to True.

labml.configs.aggregate(name: any, option_name: str, *args: Tuple[any, any])[source]

Aggregate configs

Parameters:
  • name – name of the aggregate

  • option_name – aggregate option name

  • *args – list of configs to be aggregated