What is L2 regularization?

Updated May 15, 2026

Short answer

L2 adds squared penalty to weights in cost function.

Deep explanation

It discourages large weights and improves generalization.

Real-world example

Used in ridge regression models.

Common mistakes

  • Confusing L2 with L1 sparsity effect.

Follow-up questions

  • What is ridge regression?
  • Does L2 set weights to zero?

More Cost Function interview questions

View all →