LearnQuestion bank

Why does L1 regularisation push weights exactly to zero while L2 only shrinks them? Give a geometric and a gradient-based explanation.

ResearchTechnicalEasy

Answer it yourself first, out loud or on paper, then compare.

Answer

Model answer, written in a candidate's voice

In short

  • L1 sublevel sets are diamonds/cross-polytopes with corners on the axes; loss contours often touch at a corner, forcing a coordinate to zero.
  • L2 sublevel sets are smooth spheres/ellipsoids with no axis corners, so tangency usually leaves all coordinates nonzero.
  • L1 subgradient has constant magnitude λ away from zero and an interval at zero, producing soft-thresholding/proximal updates.
  • L2 gradient is proportional to w and vanishes near zero, so weights shrink but rarely hit exactly zero.
  • Elastic net mixes L1 sparsity with L2 stability.
  • Plain SGD rarely yields exact zeros without proximal/soft-threshold or coordinate-wise updates.

In full

The core difference is that L1 penalises the sum of absolute values, so its feasible/sublevel geometry has corners on the coordinate axes, while L2 penalises the squared norm and gives a smooth spherical geometry. When the data-loss contours are pulled inward, they are much more likely to touch the L1 diamond at a corner, where one coordinate is exactly zero; with L2, the smooth contour usually meets the sphere tangentially away from the axes, so weights are shrunk but not set to zero. Gradient-wise, the L1 subgradient is λ sign(w) for w ≠ 0 and [-λ, λ] at w = 0, so it keeps pushing towards zero with constant magnitude until the loss gradient is small enough to be absorbed by that interval, which is exactly the soft-thresholding/proximal step. The L2 gradient is proportional to w, so as w approaches zero the shrinkage force also approaches zero, leaving a balance where weights are small but generally nonzero. Elastic net combines L1 and L2 to keep sparsity while adding L2 stability for correlated features. One practical caveat: plain SGD on an L1 objective does not reliably produce exact zeros; you typically need proximal updates, soft-thresholding, or coordinate descent to get exact sparsity.

Corrected by an independent AI reviewer.

What a strong answer covers

  • Geometry: the L1 ball has corners on the axes, and the loss contours tend to touch it at a corner.
  • Gradient: the L1 subgradient has constant magnitude λ even near zero, which gives soft-thresholding or proximal steps. The L2 gradient ∝ w vanishes near zero.
  • Mentions elastic net.
  • Practical caveat: plain SGD rarely produces exact zeros without proximal updates.

Common mistakes

  • Stating “L1 is sparse” without a mechanism.
  • Claiming vanilla SGD produces exact zeros.