l2_regularizer

tfsnippet.layers.l2_regularizer(lambda_, name=None)

Construct an L2 regularizer that computes the L2 regularization loss:

output = lambda_ * 0.5 * sum(input ** 2)
Parameters:
  • lambda (float or Tensor or None) – The coefficiency of L2 regularizer. If lambda_ is None, will return None.
  • name (str) – Default name of the name scope. If not specified, generate one according to the method name.
Returns:

A function that computes the L2

regularization term for input tensor. Will be None if lambda_ is None.

Return type:

(tf.Tensor) -> tf.Tensor