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
NestedHyperparamsTypeinstance.
- class HyperparamsType¶
Parent class for all dataclasses containing hyperparameters.
You will still need the
@sp.dataclassdecorator over all classes that inherit fromHyperparamsType.
- class NestedHyperparamsType¶
Bases:
HyperparamsTypeHyperparams 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:
HyperparamsTypeHyperparams for “child” datasets or models.
Subclass this dataclass and automatically create a
parentattribute for storing the hyperparams of a parent class.- parent :NestedHyperparamsType¶