scalarstop._single_namespace

Common utilities for classes that manage hyperparameters.

Module Contents

Classes

SingleNamespace

A common base class for classes with hyperparameters.

class SingleNamespace(*, hyperparams: Optional[Union[Mapping[str, Any], scalarstop.hyperparams.HyperparamsType]] = None, **kwargs)

A common base class for classes with hyperparameters.

Subclasses of this class takes hyperparameters of HyperparamsType and calculates hash-based names of the hyperparameters.

Parameters

hyperparams – The hyperparameters to initialize this class with.

Hyperparams :Type[HyperparamsType]
classmethod calculate_name(cls, *, hyperparams: Optional[Union[Mapping[str, Any], scalarstop.hyperparams.HyperparamsType]] = None)str

Calculate the hashed name of this object, given the hyperparameters.

This classmethod can be used to calculate what an object would be without actually having to call __init__().

property group_name(self)str

The “group” name is this object’s Python class name.

property name(self)str

The group (class) name and a calculated hash of the hyperparameters.

property hyperparams(self)scalarstop.hyperparams.HyperparamsType

Returns a HyperparamsType instance containing hyperparameters.

property hyperparams_flat(self)Dict[str, Any]

Returns a Python dictionary of “flattened” hyperparameters.

AppendDataBlob objects modify a “parent” DataBlob, nesting the parent’s Hyperparams within the AppendDataBlob ‘s own Hyperparams.

This makes it hard to look up a given hyperparams key. A value at parent_datablob.hyperparams.a is stored at child_datablob.hyperparams.parent.hyperparams.a.

This hyperparams_flat property provides all nested hyperparams keys as a flat Python dictionary. If a child AppendDataBlob has a hyperparameter key that that conflicts with the parent, the child’s value will overwrite the parent’s value.