yamle.regularizers.regularizer module#

class yamle.regularizers.regularizer.BaseRegularizer[source]#

Bases: ABC

This is a general class for regularizers applied to the model (L1, L2, etc.).

get_parameters(model)[source]#

This method is used to get the parameters of the model that should be regularized.

Return type:

List[Parameter]

get_names(model)[source]#

This method is used to get the names of the parameters of the model that should and should not be regularized.

Return type:

Tuple[List[str], List[str]]

on_after_training_step(model, *args, **kwargs)[source]#

This method is used to update the model after a given training step.

It can be used to implement a weight decay strategy, e.g. update the weights after each training batch by decaying them with a given factor multiplied by the learning rate.

Return type:

None

on_after_backward(model, *args, **kwargs)[source]#

This method is used to update the model after the backward pass.

It can be used to update the model after the backward pass, e.g. add noise to the gradients.

Return type:

None

on_after_train_epoch(model, *args, **kwargs)[source]#

This method is used to update the model after a given training epoch.

It can be used to add noise to the model after each training epoch.

Return type:

None

static add_specific_args(parent_parser)[source]#

This method is used to add specific arguments to the parser.

Return type:

ArgumentParser

class yamle.regularizers.regularizer.DummyRegularizer[source]#

Bases: BaseRegularizer

This is a class for a dummy regularizer that does nothing.