scalarstop.hyperparams
¶
Utilities for creating typed Python dataclasses for storing hyperparameters.
Module Contents¶
Classes¶
Parent class for all dataclasses containing hyperparameters. |
|
Hyperparams dataclass for encapsulating the hyperparams for another model. |
|
Hyperparams for "child" datasets or models. |
Functions¶
|
Convert the input into a dictionary, whether it is a dataclass or not. |
|
Return a string hash of a given Hyperparams dataclass. |
|
Construct a hyperparams object from either a mapping or another hyperparams object. |
|
Recursively flatten the hyperparams embedded |
- enforce_dict(hyperparams: Any) Dict[Any, Any] ¶
Convert the input into a dictionary, whether it is a dataclass or not.
- init_hyperparams(class_name: str, hyperparams, hyperparams_class) Any ¶
Construct a hyperparams object from either a mapping or another hyperparams object.
- flatten_hyperparams(hyperparams: Any) Dict[str, Any] ¶
Recursively flatten the hyperparams embedded in a
NestedHyperparamsType
instance.
- class HyperparamsType¶
Parent class for all dataclasses containing hyperparameters.
You will still need the
@sp.dataclass
decorator over all classes that inherit fromHyperparamsType
.
- class NestedHyperparamsType¶
Bases:
HyperparamsType
Hyperparams dataclass for encapsulating the hyperparams for another model.
When you create a dataset or model template that inherits from or combines other models, you should use this dataclass to store the hyperparams of the other model(s).
- name :str¶
- group_name :str¶
- hyperparams :HyperparamsType¶
- class AppendHyperparamsType¶
Bases:
HyperparamsType
Hyperparams for “child” datasets or models.
Subclass this dataclass and automatically create a
parent
attribute for storing the hyperparams of a parent class.- parent :NestedHyperparamsType¶