regularizer

append_regularization_ops

paddle.v2.fluid.regularizer.append_regularization_ops(parameters_and_grads, regularization=None)

Create and add backward regularization Operators

Creates and adds backward regularization operators in the BlockDesc. This will add gradients of the regularizer function to the gradients of the parameters and return these modified gradients. This is the same as implementing weight decay in optimizers for regularization.

Parameters:
  • parameters_and_grads – A list of (parameters, gradients) pairs that need to be regularized.
  • regularization – A global regularizer. If the parameter is not set. It will be applied with regularizer.
Returns:

list of (parameters, gradients) pair with the regularized gradient

Raises:

Exception – Unknown regularization type

L1Decay

paddle.v2.fluid.regularizer.L1Decay

alias of L1DecayRegularizer

L2Decay

paddle.v2.fluid.regularizer.L2Decay

alias of L2DecayRegularizer