nat.data_models.optimizable#
Attributes#
Classes#
Base class for protocol classes. |
|
Functions#
|
Module Contents#
- T#
- class _TrialLike#
Bases:
ProtocolBase class for protocol classes.
Protocol classes are defined as:
class Proto(Protocol): def meth(self) -> int: ...
Such classes are primarily used with static type checkers that recognize structural subtyping (static duck-typing).
For example:
class C: def meth(self) -> int: return 0 def func(x: Proto) -> int: return x.meth() func(C()) # Passes static type check
See PEP 544 for details. Protocol classes decorated with @typing.runtime_checkable act as simple-minded runtime protocols that check only the presence of given attributes, ignoring their type signatures. Protocol classes can be generic, they are defined as:
class GenProto[T](Protocol): def meth(self) -> T: ...
- suggest_categorical(
- name: str,
- choices: collections.abc.Sequence[Any],
- class SearchSpace(/, **data: Any)#
Bases:
pydantic.BaseModel,Generic[T]- values: collections.abc.Sequence[T] | None = None#
- model_config#
Configuration for the model, should be a dictionary conforming to [
ConfigDict][pydantic.config.ConfigDict].
- validate_search_space_parameters()#
Validate SearchSpace configuration.
- suggest(trial: _TrialLike, name: str)#
- to_grid_values() list[Any]#
Convert SearchSpace to a list of values for GridSampler.
Grid search requires explicit values. This can be provided in two ways: 1. Explicit values: SearchSpace(values=[0.1, 0.5, 0.9]) 2. Range with step: SearchSpace(low=0.1, high=0.9, step=0.2)
For ranges, step is required (no default will be applied) to avoid unintentional combinatorial explosion.
- OptimizableField(
- default: Any = PydanticUndefined,
- *,
- space: SearchSpace | None = None,
- merge_conflict: str = 'overwrite',
- **fld_kw,