L1 and L2 regularization consists in adding an additional term to the cost function that penalizes certain configurations.
For example, regularizing the cost function
 |
(5.124) |
means adding a term that is a function only of
, thereby obtaining a new cost function of the form
 |
(5.125) |
where
is a regularization function.
A widely used regularization function is
 |
(5.126) |
Common values for
are
or
(hence the names L1 and L2 regularization). When
, it may also be referred to in the literature as weight decay.
These regularization functions therefore penalize parameters with excessively large values.
Paolo medici
2026-10-01