Skip to content
LaTeX (KaTeX) templates

ML Loss Functions

MSE, cross-entropy, hinge, KL divergence, contrastive — formatted for slides.

Template previewLaTeX (KaTeX)
Rendering…

Make it your own.

\text{MSE:}\quad \mathcal L = \frac{1}{N}\sum_{i=1}^{N}(y_i - \hat y_i)^2

\text{Binary cross-entropy:}\quad \mathcal L = -\frac{1}{N}\sum_{i} \left[ y_i \log \hat y_i + (1-y_i)\log(1-\hat y_i) \right]

\text{Categorical cross-entropy:}\quad \mathcal L = -\sum_{c=1}^{C} y_c \log \hat y_c

\text{Hinge:}\quad \mathcal L = \max(0, 1 - y \hat y)

\text{KL divergence:}\quad D_{\mathrm{KL}}(p \| q) = \sum_x p(x) \log\frac{p(x)}{q(x)}

\text{InfoNCE / contrastive:}\quad \mathcal L = -\log \frac{\exp(s(q,k^+)/\tau)}{\sum_{i} \exp(s(q,k_i)/\tau)}