specsr.config

Configuration loading for the training stages.

Configs come from two places and they do not look the same:

  • Hand-written YAML, a flat mapping of name: value.

  • Weights & Biases run dumps, where every entry is wrapped as name: {value: ...} and a _wandb key carries run metadata (host, GPU, git commit, …) that is not configuration at all.

The shipped config.yaml files in this project are the second kind. Loading one naively gives every hyperparameter as the dict {"value": ...}, so float(cfg["lr"]) raises and, worse, cfg.get("dropout", 0.1) silently returns a dict that some call sites will happily pass into a layer constructor.

load_config() normalises both forms.

Functions

load_config(path, **overrides)

Load a YAML config, normalising W&B run dumps, then apply overrides.

merge_overrides(cfg, **overrides)

Return cfg updated with the non-None entries of overrides.

unwrap_wandb_config(raw)

Flatten a W&B-style {name: {value: ...}} mapping.

specsr.config.load_config(path, **overrides)[source]

Load a YAML config, normalising W&B run dumps, then apply overrides.

Overrides whose value is None are ignored, so argparse defaults can be passed straight through without clobbering the file.

Parameters:
Return type:

dict[str, Any]

specsr.config.unwrap_wandb_config(raw)[source]

Flatten a W&B-style {name: {value: ...}} mapping.

Entries that are not wrapped are passed through unchanged, so this is safe to apply to a hand-written config too. W&B metadata keys are dropped.

Parameters:

raw (dict[str, Any])

Return type:

dict[str, Any]

specsr.config.merge_overrides(cfg, **overrides)[source]

Return cfg updated with the non-None entries of overrides.

Parameters:
Return type:

dict[str, Any]