Charles Shin

From Likelihood to Loss

Contents · 4 sections

Preliminaries and Notation

PP: true distribution.
pθp_\theta: model probability mass/density.

Observations are i.i.d. from PP; all logs are natural.

Maximum likelihood estimation (MLE)

J(θ)=EX∼P[log⁡pθ(X)]≈J^(θ)=1n∑ilog⁡pθ(xi). J(\theta)=\mathbb E_{X\sim P}[\log p_\theta(X)] \approx \widehat J(\theta)=\frac1n\sum_i\log p_\theta(x_i). θ^=arg⁡max⁡θJ^(θ)=arg⁡max⁡θ∏ipθ(xi). \hat\theta =\arg\max_\theta\widehat J(\theta) =\arg\max_\theta\prod_i p_\theta(x_i).

Population objective: minimize DKL(P∥pθ)D_{\mathrm{KL}}(P\|p_\theta). The 1/n1/n is an empirical averaging weight, not a true input probability.

Conditional MLE

E(X,Y)∼P[log⁡pθ(Y∣X)]≈1n∑ilog⁡pθ(yi∣xi). \mathbb E_{(X,Y)\sim P}[\log p_\theta(Y\mid X)] \approx \frac1n\sum_i\log p_\theta(y_i\mid x_i).

Maximizing the sample average is equivalent to maximizing ∏ipθ(yi∣xi)\prod_i p_\theta(y_i\mid x_i).

For qθ(x,y)=PX(x)pθ(y∣x)q_\theta(x,y)=P_X(x)p_\theta(y\mid x), drop log⁡PX(x)\log P_X(x) because it is independent of θ\theta. A learned pθ(x)p_\theta(x) generally cannot be dropped from joint likelihood.

Gaussian regression: negative log-likelihood (NLL)

Yi∣Xi=xi∼N(μi,vi)Y_i\mid X_i=x_i\sim\mathcal N(\mu_i,v_i), where μi=μθ(xi)\mu_i=\mu_\theta(x_i), variance vi>0v_i>0, residual ri=yi−μir_i=y_i-\mu_i.

L=−1n∑ilog⁡pθ(yi∣xi)=12n∑i[log⁡(2π)+log⁡vi+ri2vi]. \mathcal L =-\frac1n\sum_i\log p_\theta(y_i\mid x_i) =\frac1{2n}\sum_i \left[\log(2\pi)+\log v_i+\frac{r_i^2}{v_i}\right].

Define MSE=1n∑iri2\mathrm{MSE}=\frac1n\sum_i r_i^2. Equivalent objectives omit parameter-independent additive constants and positive multiplicative constants.

Variance assumptionMinimize
Fixed, shared vv (homoscedastic)MSE\mathrm{MSE}
Fixed, varying viv_i (heteroscedastic)1n∑iri2/vi\frac1n\sum_i r_i^2/v_i (weighted MSE)
Learned, shared vvlog⁡v+MSE/v\log v+\mathrm{MSE}/v
Learned, varying vi=vθ(xi)v_i=v_\theta(x_i)1n∑i[log⁡vi+ri2/vi]\frac1n\sum_i[\log v_i+r_i^2/v_i]

← All writings