liveBook · Manning

Weight decay

As explained in Grokking Machine Learning

Ridge regression is a linear regression technique that uses an L2 coefficient penalty, shrinking coefficients toward zero without usually making them zero.

Weight decay, also called L2 regularization or ridge regression, discourages overly complex regression models by adding a penalty based on the L2 norm of their coefficients to the regression error. A regularization parameter controls how much that penalty matters. section 4.5

Figure 4.7 Both L1 and L2 shrink the size of the coefficient. L1 regularization (left) does it much faster, because it subtracts a fixed amount, so it is likely to eventually become zero. L2 regularization takes much longer, because it multiplies the coefficient by a small factor, so it never reaches zero.

The comparison illustrates how L2 regularization gradually shrinks coefficients, unlike L1 regularization, which can drive them to zero. section 4.5

For a polynomial regression example, compare models with no regularization, L1 regularization, and L2 regularization. The unregularized model fits training points closely but performs poorly on testing points; the L2 model fits both sets well. In Turi Create, set `l2_penalty` when creating the model. section 4.6

How Grokking Machine Learning covers it

How deep it goes
Defines the L2-penalized error and illustrates gradual coefficient shrinkage with a polynomial regression comparison.
Examples
Compares unregularized, L1-regularized, and L2-regularized polynomial models on training and testing data.
What you can do after
Apply via Turi Create by setting `l2_penalty` and comparing model performance on training and testing data.
How it connects
Connects ridge regression with L2 regularization, L1 regularization, polynomial regression, and overfitting.

Also explained in

Compare how 9 books explain weight decay →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Grokking Machine Learning. The section links point to the parts of the book it draws on.