designspace.param#
- designspace.param(name: str) FreshParamExpr#
Begin declaring a parameter called name.
This is the entry point for every parameter in a design space. The returned object is a builder: call exactly one type method on it (.real(), .integer(), .categorical(), …) to say what kind of value the parameter holds, then chain any number of modifiers (.prior(), .default(), .when(), .repeat(), …). Each call returns a new object, so a builder can be safely shared and branched.
The same call is also how you refer to an already-declared parameter inside an expression, so ds.param(“x”) < ds.param(“y”) builds a comparison, it does not redeclare anything. Which reading applies is positional: a builder passed to ds.space() declares, one used in a constraint refers.
- Parameters:
name (str) – The parameter’s name, or a path into a nested structure. A dot descends into a struct field or a choice variant’s payload (“optimizer.lr”), and [] marks the element of a lift (“stops[].dwell”).
- Returns:
A builder with no type chosen yet. Choosing a second type is an error, and the view types make it a static one too.
- Return type:
Examples
>>> lr = ds.param("lr").real(1e-4, 1e-1).log_scale() >>> depth = ds.param("depth").integer(1, 8) >>> s = ds.space(lr, depth) >>> s.n_params 2
The second reading, referring rather than declaring:
>>> s = ds.space( ... ds.param("lo").integer(0, 10), ... ds.param("hi").integer(0, 10), ... ).require(ds.param("lo") < ds.param("hi")) >>> s.is_feasible({"lo": 2, "hi": 7}) True >>> s.is_feasible({"lo": 7, "hi": 2}) False