deel.lip.regularizers module

class deel.lip.regularizers.LorthRegularizer(kernel_shape=None, stride=1, lambda_lorth=1.0, dim=2, conv_transpose=False)

Bases: Regularizer

Regularize a conv kernel to be orthogonal (all singular values are equal to 1) using Lorth regularizer.

Parameters:
  • kernel_shape – the shape of the kernel.

  • stride (int) – stride used in the associated convolution

  • lambda_lorth (float) – weight of the orthogonalization regularization.

  • dim (int) – 1 for 1D convolutions, 2 for 2D convolutions. Defaults to 2.

  • conv_transpose (bool) – whether the kernel is from a transposed convolution.

get_config()

Returns the config of the regularizer.

An regularizer config is a Python dictionary (serializable) containing all configuration parameters of the regularizer. The same regularizer can be reinstantiated later (without any saved state) from this configuration.

This method is optional if you are just training and executing models, exporting to and from SavedModels, or using weight checkpoints.

This method is required for Keras model_to_estimator, saving and loading models to HDF5 formats, Keras model cloning, some visualization utilities, and exporting models to and from JSON.

Returns:

Python dictionary.

set_kernel_shape(shape)
class deel.lip.regularizers.OrthDenseRegularizer(lambda_orth=1.0)

Bases: Regularizer

Regularize a Dense kernel to be orthogonal (all singular values are equal to 1) minimizing W.W^T-Id

Parameters:

lambda_orth (float) – regularization factor (must be positive)

get_config()

Returns the config of the regularizer.

An regularizer config is a Python dictionary (serializable) containing all configuration parameters of the regularizer. The same regularizer can be reinstantiated later (without any saved state) from this configuration.

This method is optional if you are just training and executing models, exporting to and from SavedModels, or using weight checkpoints.

This method is required for Keras model_to_estimator, saving and loading models to HDF5 formats, Keras model cloning, some visualization utilities, and exporting models to and from JSON.

Returns:

Python dictionary.