designspace.unflatten#
- designspace.unflatten(flat: dict[str, Any], space: Space) dict[str, Any]#
Rebuild a nested configuration from one keyed by path.
The inverse of ds.flatten(), and the way back from a solver’s flat view to the shape .validate() and .sample_one() speak.
- Parameters:
- Returns:
The configuration in nested form.
- Return type:
Examples
>>> s = ds.space( ... ds.param("opt").choice(sgd=ds.space(ds.param("momentum").real(0, 1))), ... ds.param("lr").real(0, 1), ... ) >>> flat = {"opt": "sgd", "opt.sgd.momentum": 0.5, "lr": 0.1} >>> ds.unflatten(flat, s) {'opt': {'sgd': {'momentum': 0.5}}, 'lr': 0.1}