Skip to content
Middle+0 views

Why do weights become zero right away with L1 regularization (geometric interpretation)?

Practice

Asked at

AI answer

L1 regularization adds a penalty (\lambda\sum_j |w_j|) to the loss function. Geometrically, the set of solutions with the same L1 penalty is a diamond (in two dimensions) with vertices on the axes. The level sets of the original loss function expand until they first touch this region; the point of contact is often a vertex where one or more coordinates are zero. Therefore, L1 often produces sparse weights.

The same result follows from the optimality condition: for a nonzero weight, the penalty adds a gradient of (\lambda,\mathrm{sign}(w_j)), while at zero the subgradient lies in the interval ([-\lambda,\lambda]). If the loss gradient along a coordinate is sufficiently small, the optimality condition is satisfied at (w_j=0). This does not mean that every weight will necessarily become zero: the result depends on the data and the strength of regularization.