Base class for regularizers.

Regularizer objects introduce penalties to a model’s cost function. This is done by applying them on desired layers using their weight_regularizer and/or bias_regularizer arguments.


This is a base class and it is not intended to be called directly. Users are expected to instantiate each of its subclasses directly.

Available regularizers


In the case of L2 regularization, the penalty can be passed into supported layers (e.g., as either a weight_regularizer or bias_regularizer argument, as follows:

>>> import usencrypt as ue
>>> l2_reg =
>>> layer =, 4, weight_regularizer=l2_reg)