A regularizer that applies a L2 regularization penalty.

Inherits From: Regularizer

Used in the notebooks

Used in the guide Used in the tutorials

The L2 regularization penalty is computed as: loss = l2 * reduce_sum(square(x))

L2 may be passed to a layer as a string identifier:

dense = tf.keras.layers.Dense(3, kernel_regularizer='l2')

In this case, the default value used is l2=0.01.

l2 Float; L2 regularization factor.



View source

Creates a regularizer from its config.

This method is the reverse of get_config, capable of instantiating the same regularizer from the config dictionary.

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

config A Python dictionary, typically the output of get_config.

A regularizer instance.


View source

Returns the config of the regularizer.

An regularizer config is a Python dictionary (seriali