> For the complete documentation index, see [llms.txt](https://ztlevi.gitbook.io/ml-101/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://ztlevi.gitbook.io/ml-101/loss/l1-and-l2-loss.md).

# L1 and L2 Loss

### L1 Loss vs L2 Loss

* **Robustness**: L1 > L2

  Intuitively speaking, since a L2-norm squares the error (increasing by a lot if error > 1), the model will see a much larger error than the L1-norm, so the model is much more sensitive to outliers.
* **Stability**: L2 > L1

  In the case of a more “outlier” point, both norms still have big change, but again the L1-norm has more changes in general.
* **Solution uniqueness**: Minimizing the L2 loss corresponds to calculating **the arithmetic mean**, which is unambiguous, while minimizing the L1 loss corresponds to calculating **the median**, which is ambiguous if an even number of elements are included in the median calculation, So L2 has unique solution while L1 has multiple solution
* Smooth l1 loss

![img](/files/skpb5aiIsUUOaPa9tUd1)

Smooth L1 loss that is less sensitive to outliers than the L2 loss used in R-CNN and SPPne.
