liveBook · Manning

L1 regularization

As explained in Deep Learning with Python, Third Edition

A regularization method that penalizes the absolute values of weights to encourage sparsity.

L1 regularization discourages overfitting by adding a cost proportional to each weight’s absolute value. It favors models whose weight distribution is more regular and can encourage sparse weights. section 5.4.4

Adding L1 regularization in Keras

Keras exposes L1 weight regularization through a layer’s regularizer argument, for example regularizers.l1(0.001). The same API also supports combining L1 and L2 penalties with l1_l2.

Use L1 regularization as a practical option when:

  • A small deep learning model is overfitting and needs an additional constraint on its weights. section 5.4.4
  • You are iterating on architectures and hyperparameters using validation performance, while avoiding repeated overfitting to the validation process. section 6.2.5

How Deep Learning with Python, Third Edition covers it

How deep it goes
Defines the absolute-value penalty and shows its Keras declaration, but does not work through L1 training behavior or results.
Examples
Uses Keras declarations for L1 and combined L1/L2 regularizers within a broader IMDb classification example.
What it assumes
Assumes familiarity with model weights, loss functions, overfitting, and Keras layers while defining the penalty itself.
What you can do after
Apply it via Keras by passing an L1 regularizer to a layer’s weight-regularizer argument.
How it connects
Connects L1 regularization with overfitting, weight regularization, L2 regularization, dropout, and hyperparameter tuning.

Also explained in

Compare how 6 books explain L1 regularization →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Deep Learning with Python, Third Edition. The section links point to the parts of the book it draws on.