traced_hp

Module to specify the basic hyperparameter with tracing capabilities.

Classes

TracedHpRegistry

A simple registry to keep track of different traced hp classes and their symbols.

TracedHp

A hparam that exhibits additional functionality required to handle tracing.

class TracedHp

Bases: Hparam

A hparam that exhibits additional functionality required to handle tracing.

classmethod initialize_from(hp)

Initialize a new hparam from an existing vanilla Trace.

Parameters:

hp (Hparam) –

Return type:

TracedHp

resolve_dependencies(sym, get_hp)

Resolve dependencies of the hparam via symbolic map.

This method iterates through the dependency map described in sym and generates an appropriate hparam based on the currently assigned hparam and the parent symbol.

Parameters:
  • sym (Symbol) – The symbol associated with self for which we want to resolve dependencies.

  • get_hp (Callable[[Symbol], TracedHp]) – A function that returns the hparam associated with a symbol.

Returns:

A mapping describing the hparam that should be associated with each symbol.

Return type:

Dict[Symbol, TracedHp]

class TracedHpRegistry

Bases: object

A simple registry to keep track of different traced hp classes and their symbols.

classmethod get(sym)

Get Hparam type associated with symbol.

Parameters:

sym (Symbol) –

Return type:

Type[TracedHp] | None

classmethod initialize_from(sym, hp)

Initialize the sym-appropriate hparam from a vanilla hparam.

Parameters:
Return type:

TracedHp

classmethod register(sym_cls)

Use this to register a new traced hparam class for the provided symbol class.

Usage:

@TracedHpRegistry.register(MySymbol)
class MyHparam(TracedHp):
    pass
Parameters:

sym_cls (Type[Symbol]) –

Return type:

Callable[[Type[TracedHp]], Type[TracedHp]]

classmethod unregister(sym_cls)

Unregister a previously registered symbol class.

It throws a KeyError if the hparam class is not registered.

Parameters:

sym_cls (Type[Symbol]) –

Return type:

None