accelmo.optimisers.base¶
Abstract optimiser interface and best-point tracking.
- class accelmo.optimisers.base.BestTracker[T](value, loss=inf)[source]¶
Bases:
Generic[T]The lowest loss seen so far and the point it was seen at.
- Parameters:
value (T)
loss (float)
- value: T¶
- loss: float = inf¶
- class accelmo.optimisers.base.BaseOptimiser[source]¶
Bases:
ABCCommon interface for all optimisers used by the training loop.
Subclasses are named by
OPTIMISER_NAME, take their constructor arguments from anOptimiserConfigviaconfig_kwargs(), and list inKNOB_VECTORS/KNOB_VECTOR_LISTSthe state entries that hold one value per knob, whichload_state_dict()remaps when the knob layout changed.- OPTIMISER_NAME: ClassVar[str]¶
- KNOB_VECTORS: ClassVar[tuple[str, ...]] = ()¶
State entries that are one vector over the knobs (
Noneallowed).
- KNOB_VECTOR_LISTS: ClassVar[tuple[str, ...]] = ()¶
State entries that are a list of such vectors.
- abstractmethod classmethod config_kwargs(config, n_params)[source]¶
Constructor arguments taken from
config.- Return type:
dict[str,Any]- Parameters:
config (OptimiserConfig)
n_params (int)
- abstractmethod step(params, grads, lr)[source]¶
Apply one optimisation update step.
- Return type:
ndarray- Parameters:
params (np.ndarray)
grads (np.ndarray)
lr (float)
- abstractmethod state_dict()[source]¶
Serialise optimiser state to a JSON-compatible dictionary.
- Return type:
dict[str,Any]