Home/AI/ML Notes/Deep Learning and Machine Learning/Regularization: L1, L2 & Beyond
⌂ Main Page
Deep Learning and Machine Learning

Regularization: L1, L2 & Beyond

L1/L2 regularization, regression variants with regularization, dropout and other techniques.

On this page

L1 and L2 Regularization

Regularization - adding a penalty term to the cost function to discourage the weights from getting large.

L2 or Ridge regularization - minimizes the squared magnitude of weights, shrinks all the coefficient by the same proportions, but eliminates none.

L1 or Lasso penalty – minimizes absolute value of weights, can shrink to zero some coefficients (feature selection).

Regressions summary

A poster of a math problem AI-generated content may be incorrect.

Linear Regression - More Details

Simplest - sum of squares of all coefficients => modified linear regr error function:

lambda = regularization parameter.

To minimize error - gradient descent algo = keep updating the model parameters to move closer to the values causing min. cost.

repeat until convergence ( with regularization):

With some manipulation the above equation can also be represented as:

First term (1 – alpha*lambda/m) always < 1 and reduces coeff by some amount on every update.

Logistic Regression

Cost function with regularization:

Where g() is the sigmoid (logistic) f(x):

A math equations and symbols AI-generated content may be incorrect.

Other Forms of Regularization

Explicit Regularization

These are techniques that add a direct penalty term to the loss function or explicitly constrain the model:

  1. Elastic Net → Combines L1 (Lasso) and L2 (Ridge) penalties.

  2. Group Lasso / Sparse Group Lasso → Promotes sparsity at the group or feature-block level.

  3. Max-norm regularization → Constrains the norm of the weight vector to be below a fixed threshold.

  4. Weight decay → Equivalent to L2 regularization but implemented directly in the optimization step.

  5. Orthogonality regularization → Encourages weight matrices (especially in RNNs or CNNs) to be close to orthogonal, improving stability.

  6. Spectral norm regularization → Constrains the largest singular value of a weight matrix, controlling Lipschitz constants.

  7. Nuclear norm regularization → Promotes low-rank solutions by penalizing the sum of singular values.

  8. Label smoothing → Regularizes classification by softening one-hot targets.

🔹 Implicit Regularization

These are methods that don’t add an explicit penalty, but the procedure itself biases the model toward simpler or more generalizable solutions:

  1. Early stopping → Stops training before overfitting occurs, preventing weights from fitting noise.

  2. Dropout (sometimes considered explicit) → Adds stochastic regularization by randomly zeroing activations during training.

  1. Stochastic Gradient Descent (SGD) dynamics → SGD has an implicit bias toward flatter minima, which generalize better.

  2. Batch normalization / Layer normalization → Normalize activations, implicitly regularizing the model by reducing internal covariate shift.

  3. Data augmentation → Artificially enlarges the dataset (flips, rotations, mixup, CutMix, etc.), reducing overfitting.

  4. Noisy training → Adding noise to inputs, hidden activations, or weights (Gaussian noise, dropout) improves robustness.

  5. Smaller architectures / parameter sharing → CNN weight sharing, low-rank factorization, or pruning implicitly regularize by limiting capacity.

  6. Ensembling / Bagging → Training multiple models and averaging predictions reduces variance.

  7. Self-distillation / Knowledge distillation → Training with a teacher model’s soft predictions guides smoother decision boundaries.

  8. Learning rate schedules → Large-to-small learning rates (cosine, step decay, 1-cycle) bias optimization toward simpler minima.

Summary: