Regularization (L1 & L2)

L1 regularization:

L1 regularization, also known as Lasso regularization, is a technique used in neural networks to prevent overfitting and promote sparsity in the learned weights. It adds a penalty term to the loss function, proportional to the absolute value of the weights. This encourages the network to prioritize and select important features while shrinking less important weights toward zero. L1 regularization effectively performs feature selection by pushing irrelevant weights to zero, resulting in a simpler and more interpretable model. It can help prevent overfitting and improve the generalization ability of the network by reducing the complexity and encouraging a more sparse representation of the learned weights.

L2 regularization:

L2 regularization, also known as Ridge regularization, is a technique used in neural networks to mitigate overfitting and control the complexity of the model. It adds a penalty term to the loss function, proportional to the squared magnitude of the weights. This encourages the network to minimize the overall weight values, effectively shrinking them towards zero. L2 regularization helps to prevent overly large weights, making the model more robust to noise and reducing the sensitivity to small changes in the input data. It encourages a more generalized solution by promoting a smoother and more distributed weight distribution. L2 regularization is widely used in neural networks to improve model generalization and prevent overfitting.