deep learningstatistical learningbias-variance tradeoff
Bias and variance are usually studied at the end of training. Here, we instead track how they evolve during optimization, one epoch at a time.
Suppose that we are training a model parameterized by θ, and let θt denote the parameters at step t produced by the optimization algorithm of our choice. In machine learning, it is often helpful to decompose the error E(θ) as B2(θ)+V(θ)+N(θ), where B represents the bias, V the variance, and N the noise (irreducible error). In most cases, the decomposition is performed at an optimal solution θ∗—for instance, limt→∞θt, or an early-stopped version—to understand how bias and variance change with model complexity, model size, and related quantities. This has helped explain phenomena such as As model capacity grows, test error may first decrease, then increase near the interpolation threshold, and finally decrease again in the overparameterized regime.. It can also be useful to visualize how B(θt) and V(θt) evolve with t, which can help explain For a fixed model, test error can decrease, rise around the time the training data are fitted, and then decrease again as training continues.. That is what we will study in this post.
Source An earlier version of these notes is available on HackMD.
Notations
X : domain set (input space)
Y : label set (output space)
H : hypothesis class (class of possible models we can learn)
Definitions and preliminaries
Definition 1Loss function. The loss function ℓ(t,y) takes two labels, produces a value between 0 and some constant M∈[0,∞], and measures the cost of predicting y when the true value is t.
ℓ:Y×Y(t,y)→[0,M]↦ℓ(t,y)
Examples include square loss ℓ(t,y)=(t−y)2, absolute loss ℓ(t,y)=∣t−y∣, and zero-one loss ℓ(t,y)=1{t=y}.
Definition 2Training set. Let S be a set of ∣S∣ observations zi=(xi,ti)∈X×Y, where xi∈X is a feature vector and ti∈Y is the label of the i-th sample. The observations are assumed to be i.i.d. means independent and identically distributed: every zi follows the same distribution D, and observing one sample does not change the distribution of the others. draws from an unknown data distribution D.
S={z1,⋯,zn}
Since training-set size is an important parameter of a learning problem, we assume below that all datasets have the same size n.
Definition 3Optimal prediction.
Let x be random and let t=t(x) be either deterministic or random conditional on x. The The joint distribution of an input and label equals the marginal distribution of the input multiplied by the conditional distribution of the label given that input. gives the optimal prediction at x as
y∗(x)=argyminEt∼p(t∣x)[ℓ(t,y)].
In the deterministic case, there exists t∈Y such that p(t∣x)=1, and therefore y∗(x)=argminyℓ(t,y)=t.
Thus the optimal prediction is the As a function of y, the expected square loss is a convex quadratic. Its derivative is 2(y−E[t∣x]), which vanishes at y=E[t∣x]. of p(t∣x). For example, suppose that, for a fixed x, (x,1) occurs with probability px∈[0,1] and (x,0) occurs with probability 1−px:
t(x)={1,0,with probability px,with probability 1−px.
where Ft∣x is the Ft∣x(u)=P(t≤u∣x). Its generalized inverse is Ft∣x−1(q)=inf{u:Ft∣x(u)≥q}, which remains meaningful for discrete distributions.. Thus y∗(x) is a median of p(t∣x).
The last line follows because y↦2Ft∣x(y)−1 is the derivative of the function
That is the A mode is any label with maximal conditional probability p(t∣x). Predicting it minimizes the probability of misclassification under zero-one loss.. For the same Bernoulli example, we have
Definition 4Learning algorithm. A learning algorithm is a map A:(X×Y)n→H. It takes a dataset S∈(X×Y)n containing n samples and returns a model h=A(S)∈H.
The optimal model satisfies f(x)=y∗(x) for every x. Under zero-one loss, this is the The Bayes classifier predicts a most probable class conditional on x. The smallest classification error it can attain is the Bayes rate; this is the irreducible classification error induced by class overlap or label noise.. In the binary example above, it is f(x)=1{P(t=1∣x)≥1/2}.
Definition 5True risk. Given h∈H,
R[h]=E(x,t)∼D[ℓ(t,h(x))]
Definition 6Empirical risk. For h∈H and S={(x1,t1),…,(xn,tn)},
R^S[h]=n1i=1∑nℓ(ti,h(xi))
The essential task of supervised learning is to obtain good performance on unseen data by adjusting h using one sampled training set S. The True risk averages over the unknown population distribution D; empirical risk averages over the finite observed training set. Generalization concerns how well the latter controls the former.. We recall them mainly to make the dependence h=A(S) explicit.
Definition 7Expected loss at an input.
Since the same learner A generally produces different models h for different training sets S, the loss ℓ(t,h(x)) depends on S through h=A(S). We expose this dependency by averaging over training sets.
Let Dn be a collection of training sets of size n, let y^n(x) denote the prediction at x obtained by applying the learner to a sampled training set, and let Yn(x)={A(S)(x):S∈Dn} be the A multiset keeps multiplicity: the same numerical prediction appears several times when several training sets produce it. Equivalently, one may regard Yn(x) as the empirical distribution induced by sampling S from Dn..
Our objective is to decompose En(x) into three terms: bias, variance, and noise (irreducible error). A standard decomposition exists for square loss, and several alternatives have been proposed for zero-one loss.
Definition 8Main prediction. For a loss function ℓ and a collection of training sets Dn, the main prediction is
In words, the main prediction minimizes its average loss relative to all predictions in Yn(x). It is the prediction that “differs least” from the learner’s possible predictions according to ℓ, and therefore describes their central tendency.
Remark The main prediction need not belong to Yn(x). For example, the mean of finitely many predictions can lie strictly between all observed values.
Theorem 1 Under square loss, the main prediction is the mean of Yn(x); under absolute loss, it is a median; and under zero-one loss, it is a mode (a most frequent prediction).
Proof for the mean, median, and mode
Under square loss, the main prediction is the mean because
In words, the square bias is the loss of the main prediction relative to the optimal prediction; the variance is the average loss of individual learned predictions relative to the main prediction; and the noise is the unavoidable component, independent of the learning algorithm. In the deterministic case, N(x)=ℓ(t(x),t(x)) for every x.
Bias and variance may be averaged over all examples, in which case we will refer to them as average square bias
Ex∼p(x)[B2(x)]
and average variance
Ex∼p(x)[V(x)].
The average noise is
Ex∼p(x)[N(x)]=E(x,t)∼p(x,t)[ℓ(t,y∗(x))]
Theorem 2 For square loss ℓ(t,y)=(t−y)2,
V(x)=Ey∼Yn(x)[y2]−(yℓ,Dn(x))2 and N(x)=Et∼p(t∣x)[t2]−(y∗(x))2Proof of the variance and noise identitiesV(x)=Ey∼Yn(x)[(yℓ,Dn(x)−y)2]=Ey∼Yn(x)[(yℓ,Dn(x))2]−2yℓ,Dn(x)Ey∼Yn(x)[y]+Ey∼Yn(x)[y2]=(yℓ,Dn(x))2−2(yℓ,Dn(x))2+Ey∼Yn(x)[y2]=Ey∼Yn(x)[y2]−(yℓ,Dn(x))2N(x)=Et∼p(t∣x)[(t−y∗(x))2]=Et∼p(t∣x)[t2]−2y∗(x)Et∼p(t∣x)[t]+Et∼p(t∣x)[(y∗(x))2]=Et∼p(t∣x)[t2]−2(y∗(x))2+(y∗(x))2=Et∼p(t∣x)[t2]−(y∗(x))2
Bias-variance decomposition
For a given loss function ℓ, we seek two constants c1(x,ℓ) and c2(x,ℓ) such that
En(x)=B2(x)+c1(x,ℓ)V(x)+c2(x,ℓ)N(x)
Theorem 3 For square loss ℓ(t,y)=(t−y)2, c1(x,ℓ)=c2(x,ℓ)=1.
Proof of the square-loss decompositionEn(x)=Ey∼Yn(x),t∼p(t∣x)[(t−y)2]=Ey∼Yn(x),t∼p(t∣x)[(t−y∗(x)+y∗(x)−y)2]=Et∼p(t∣x)[(t−y∗(x))2]+2(Et∼p(t∣x)[t]−y∗(x))(y∗(x)−Ey∼Yn(x)[y])+Ey∼Yn(x)[(y∗(x)−y)2]=N(x)+2×0×(y∗(x)−Ey∼Yn(x)[y])+Ey∼Yn(x)[(y∗(x)−yℓ,Dn(x)+yℓ,Dn(x)−y)2]=N(x)+(y∗(x)−yℓ,Dn(x))2+2(y∗(x)−yℓ,Dn(x))(yℓ,Dn(x)−Ey∼Yn(x)[y])+Ey∼Yn(x)[(yℓ,Dn(x)−y)2]=N(x)+B2(x)+2(y∗(x)−yℓ,Dn(x))×0+V(x)=B2(x)+V(x)+N(x)
Let PDn(x)=P[y∗(x)∈Yn(x)] be the probability over training sets in Dn that the learner predicts the optimal class for x.
Theorem 4 For zero-one loss ℓ(t,y)=1{t=y} in binary classification, c1(x,ℓ)=2PDn(x)−1 and c2(x,ℓ)=21{yℓ,Dn(x)=y∗(x)}−1.