fluid.regularizer

L1Decay

paddle.fluid.regularizer.L1Decay

alias of L1DecayRegularizer

L1DecayRegularizer

class paddle.fluid.regularizer.L1DecayRegularizer(regularization_coeff=0.0)

Implements the L1 Weight Decay Regularization

L1 regularization encourages sparsity.

\[L1WeightDecay = reg\_coeff * sign(parameter)\]
Parameters:regularization_coeff (float) – regularization coeff

Examples

optimizer = fluid.optimizer.Adagrad(
    learning_rate=1e-4,
    regularization=fluid.regularizer.L1DecayRegularizer(
        regularization_coeff=0.1))
optimizer.minimize(avg_cost)

L2Decay

paddle.fluid.regularizer.L2Decay

alias of L2DecayRegularizer

L2DecayRegularizer

class paddle.fluid.regularizer.L2DecayRegularizer(regularization_coeff=0.0)

Implements the L2 Weight Decay Regularization

Small values of L2 can help prevent over fitting the training data.

\[L2WeightDecay = reg\_coeff * parameter\]
Parameters:regularization_coeff (float) – regularization coeff

Examples

optimizer = fluid.optimizer.Adagrad(
    learning_rate=1e-4,
    regularization=fluid.regularizer.L2DecayRegularizer(
        regularization_coeff=0.1))
optimizer.minimize(avg_cost)