A norm measures the "size" of a vector. Norms underlie nearly every loss function, regularizer, and similarity measure in ML.
Common norms ( family):
| Norm | Formula | Use in ML |
|---|---|---|
| (Manhattan) | Lasso regression, sparse solutions | |
| (Euclidean) | Default distance, Ridge regression, weight decay | |
| (Max) | Adversarial robustness (perturbation budgets) | |
| (pseudo-norm) | count of nonzero entries | Sparsity (NP-hard to optimize, is the convex relaxation) |
Frobenius norm for matrices: — the norm of a matrix flattened into a vector.
Key distance metrics:
- Euclidean distance:
- Cosine similarity: — measures angle, ignores magnitude. Dominant in embeddings and retrieval
- Mahalanobis distance: accounts for covariance structure — Euclidean distance after whitening
Why this matters everywhere:
- Regularization is just adding a norm penalty: → sparsity, → small weights
- Loss Functions are often norms of the residual: MSE = squared , MAE =
- Cosine similarity is the scoring function inside Self-Attention (after normalization by )
See also: Dot Product, Regularization, Embeddings