mlektic.methods package

Subpackages

Submodules

mlektic.methods.optimizer_archt module

mlektic.methods.optimizer_archt.optimizer_archt(method: str = 'sgd', learning_rate: float = 0.01, momentum: float = 0.0, nesterov: bool = False, batch_size: int = 32) tuple[source]

Returns the optimizer, training method, and batch size based on the specified method.

Parameters:
  • method (str, optional) – The optimization method to use. Default is ‘sgd’. Supported methods are: ‘sgd-standard’, ‘sgd-stochastic’, ‘sgd-mini-batch’, ‘sgd-momentum’, ‘nesterov’, ‘adagrad’, ‘adadelta’, ‘rmsprop’, ‘adam’, ‘adamax’, ‘nadam’.

  • learning_rate (float, optional) – Learning rate for the optimizer. Default is 0.01.

  • momentum (float, optional) – Momentum for optimizers that support it. Default is 0.0.

  • nesterov (bool, optional) – Whether to use Nesterov momentum. Default is False.

  • batch_size (int, optional) – Batch size for mini-batch optimization. Default is 32.

Returns:

A tuple containing the optimizer instance, the training method, and the batch size.

The batch size is None for methods that do not use mini-batch training.

Return type:

tuple

Raises:

ValueError – If the specified method is not supported.

mlektic.methods.regularizer_archt module

mlektic.methods.regularizer_archt.regularizer_archt(method: str = 'l1', lambda_value: float = 0.1, alpha: float = 0.5) Callable[[Tensor], Tensor][source]

Returns a regularization function based on the specified method.

Parameters:
  • method (str, optional) – The regularization method to use. Default is ‘l1’. Supported methods are ‘l1’, ‘l2’, ‘elastic_net’.

  • lambda_value (float, optional) – Regularization parameter. Default is 0.1.

  • alpha (float, optional) – Mixing parameter for elastic net regularization, with 0 <= alpha <= 1. Default is 0.5.

Returns:

A function that takes weights as input and returns the regularization term.

Return type:

Callable[[tf.Tensor], tf.Tensor]

Raises:

ValueError – If the specified method is not supported.

Module contents