Config¶
- class aido.config.AIDOConfig(optimizer: ~aido.config.OptimizerConfig = <factory>, surrogate: ~aido.config.SurrogateConfig = <factory>, simulation: ~aido.config.SimulationConfig = <factory>, scheduler: ~aido.config.SchedulerConfig = <factory>)[source]
Bases:
objectConfig Dataclass for storing the internal parameter such as the hyperparameters of the different models and the way new values are sampled for the Simulation Task.
This class is serializable to and from json. In order to be picked up by the AIDO scheduler, the json file with updated values must be placed in the AIDO root directory.
Default fields:
- Optimizer:
optimizer.lr: float = 0.02 (>0)
optimizer.batch_size: int = 512
optimizer.n_epochs: int = 40
- Surrogate:
surrogate.n_epoch_pre: int = 24
surrogate.n_epochs_main: int = 40
- Simulation:
simulation.generate_scaling: float = 1.2 (>0)
simulation.sigma: float = 1.5 (>0)
simulation.sigma_mode: str = “flat” (or “scale”)
- Scheduler:
scheduler.training_num_retries: int = 20
scheduler.training_delay_between_retries: int | float = 60 (in seconds)
- __getitem__(key: str) Any[source]
See
AIDOConfig.get_value()
- as_dict() Dict[source]
Return all values from this Config class as a dict
- Returns:
dict – Nested dictionary with subclasses also being dicts
- from_dict(new_dict: dict) None[source]
Update values from this instance with values from the provided dict.
- Parameters:
new_dict (dict) – A dictionary with the new values, with the keys being in the dot-separated format used by
AIDOConfig.set_value()
- classmethod from_json(file_path: str) Self[source]
Create a new instance from a json file
- Parameters:
file_path (str) – The input file path
- Returns:
AIDOConfig – New instance of this class
- Raises:
Warning – If the file could not be found, a warning is displayed instead of raising a FileNotFoundError. This is to ensure that the code can still run despite an invalid config.
Warning – If any Exception is raised while reading in the json file, e.g. if it is invalid or wrongly formatted, a warning is displayed. Will show the Error message for debugging.
- get_key(key: str) Tuple[Self, Any][source]
Helper method to find the subclass that corresponds to a given dot-separated name.
- Parameters:
key (str) – A dot-separated name. For example “optimizer.lr”.
- Returns:
tuple – A tuple of the sub-class together with the attribute name.
Example
>>> AIDOConfig.get_key("optimizer.lr") (OptimizerConfig(lr=0.02, batch_size=512, n_epochs=40), 'lr')
Where the first entry is an instance of the
OptimizerConfigsubclass and the second entry is the key that can be used to access that attribute.>>> getattr(OptimizerConfig, "lr") 0.02
- get_value(key: str) Any[source]
Get the value from one of the subclasses
- Parameters:
key (str) – A dot-separated name
- Returns:
Any – The attribute value corresponding to the key
- set_value(key: str, value: Any) None[source]
Change the value of a field by providing a dot-separated key and value
- Parameters:
key (str) – dot-separated name, for example “optimizer.lr” will adjust the attribute “lr” of the sub-class
OptimizerConfig.value (Any) – The updated value
- to_json(file_path: str) None[source]
Write the current values to a json file
- Parameters:
file_path (str) – The output file path
- class aido.config.OptimizerConfig(lr: float = 0.02, batch_size: int = 512, n_epochs: int = 40)[source]
Bases:
object
- class aido.config.SchedulerConfig(training_num_retries: int = 20, training_delay_between_retries: int | float = 60)[source]
Bases:
object
- class aido.config.SimulationConfig(generate_scaling: float = 1.2, sigma: float = 1.5, sigma_mode: str = 'flat')[source]
Bases:
object
- class aido.config.SurrogateConfig(n_epoch_pre: int = 24, n_epochs_main: int = 40)[source]
Bases:
object