fluke.config

Configuration

Fluke configuration class.

ConfigurationError

Exception raised when the configuration is not valid.

OptimizerConfigurator

This class is used to configure the optimizer and the learning rate scheduler.

class fluke.config.Configuration

class fluke.config.Configuration(config_exp_path: str = None, config_alg_path: str = None, force_validation: bool = True)[source]

Fluke configuration class. This class is used to store the configuration of an experiment. The configuration must adhere to a specific structure. The configuration is validated when the class is instantiated.

Parameters:
  • config_exp_path (str) – The path to the experiment configuration file.

  • config_alg_path (str) – The path to the algorithm configuration file.

  • force_validation (bool, optional) – Whether to force the validation of the configuration. Defaults to True.

Raises:

ValueError – If the configuration is not valid.

property client: DDict

Get quick access to the client’s hyperparameters.

Returns:

The client’s hyperparameters.

Return type:

DDict

classmethod from_dict(cfg_dict: dict | DictConfig) Configuration[source]

Create a configuration from a dictionary.

Parameters:

cfg_dict (dict | DictConfig) – The dictionary.

Returns:

The configuration.

Return type:

Configuration

property model: DDict

Get quick access to the model hyperparameters.

Returns:

The model hyperparameters.

Return type:

DDict

property server: DDict

Get quick access to the server’s hyperparameters.

Returns:

The server’s hyperparameters.

Return type:

DDict

classmethod sweep(config_exp_path: str, config_alg_path: str) list[Configuration][source]

Generate configurations from a sweep. This method is used to generate configurations from a sweep. The sweep is defined by the experiment configuration file. The method yields a configuration for each combination of hyperparameters.

Parameters:
  • config_exp_path (str) – The path to the experiment configuration file.

  • config_alg_path (str) – The path to the algorithm configuration file.

Returns:

A list of configurations.

Return type:

list[Configuration]

to_dict() dict[source]

Convert the configuration to a dictionary.

Returns:

The dictionary.

Return type:

dict

class fluke.config.ConfigurationError

class fluke.config.ConfigurationError[source]

Exception raised when the configuration is not valid.

class fluke.config.OptimizerConfigurator

class fluke.config.OptimizerConfigurator(optimizer_cfg: DDict | dict, scheduler_cfg: DDict | dict = None)[source]

This class is used to configure the optimizer and the learning rate scheduler.

optimizer

The optimizer class.

Type:

type[Optimizer]

scheduler

The learning rate scheduler class.

Type:

type[LRScheduler]

optimizer_cfg

The optimizer keyword arguments.

Type:

DDict

scheduler_cfg

The scheduler keyword arguments.

Type:

DDict

__call__(model: Module, filter_fun: callable | None = None, **override_kwargs)[source]

Creates the optimizer and the scheduler.

Parameters:
  • model (Module) – The model whose parameters will be optimized.

  • filter_fun (callable) – This must be a function of the model and it must returns the set of parameters that the optimizer will consider.

  • override_kwargs (dict) – The optimizer’s keyword arguments to override the default ones.

Returns:

The optimizer and the scheduler.

Return type:

tuple[Optimizer, StepLR]