Lesson 4 of 6 8 min · 126 words
L2 regularization
Shrinking weights smoothly; always gives a unique solution.
L2 regularisation (ridge, weight decay) adds to the loss. Large weights are expensive, so the model spreads influence across features and becomes smoother and less sensitive to small input changes.
For linear regression it has the closed form . The added makes the matrix always invertible, so there is always a unique solution — even with correlated features or more features than examples.
In gradient descent, the penalty adds to the gradient, so each step first shrinks the weights by a constant factor — hence the name weight decay.
Formula to remember
Ridge closed form
λI keeps the matrix invertible.
Quick check · +5 XP