ksuit.factory.optim_factory

Classes

OptimizerFactory

Factory for creating optimizers. Handles wrapping into OptimerWrapper by creating the corresponding constructor

Module Contents

class ksuit.factory.optim_factory.OptimizerFactory

Bases: ksuit.factory.base.Factory

Factory for creating optimizers. Handles wrapping into OptimerWrapper by creating the corresponding constructor for the underlying torch.optim.Optimizer. Objects are returned as partials, as creating the optimizer requires the model parameters from the instantiated model.

instantiate(optimizer_config)

Instantiates the model either based on kind and kwargs or from the checkpoint.

Parameters:

optimizer_config (ksuit.schemas.optim.OptimizerConfig) – config for the optimizer to create. This config contains both the torch optimizer and the OptimerWrapper configurations.

Returns:

A callable that initializes the optimizer.

Return type:

collections.abc.Callable[[Ellipsis], ksuit.optimizer.OptimizerWrapper]