WHY this matters: MSE and cross-entropy are not two random formulas to memorize — they are the same recipe (NLL) applied to two different noise models (Gaussian vs. Categorical).
Every standard loss is the negative log-likelihood of what?
The data under an assumed noise/probability model.
MSE arises from assuming what noise distribution on targets?
Gaussian (normal) noise, ε∼N(0,σ2).
Write the MSE formula.
n1∑i(yi−y^i)2.
Why do we square the error in MSE?
To make it positive and to penalize large errors more heavily.
Gradient of 21(y−y^)2 w.r.t. y^?
y^−y (the error itself).
Cross-entropy arises from assuming what distribution?
Bernoulli (binary) / Categorical (multi-class).
Write binary cross-entropy.
−[ylogy^+(1−y)log(1−y^)].
Write multi-class cross-entropy with one-hot y.
−∑kyklogy^k=−logy^true.
Gradient of softmax+CE w.r.t. logit zk?
y^k−yk.
Why not use MSE for classification?
Sigmoid+MSE gradient saturates (vanishes) when confidently wrong; CE keeps gradient y^−y.
BCE when y^=0.5 and y=1?
ln2≈0.693 (the coin-flip baseline).
What must the input to CE's log be?
A valid probability in (0,1), so apply softmax/sigmoid first.
Recall Feynman: explain to a 12-year-old
Imagine a dartboard. The loss is how far your dart landed from the bullseye. For guessing a number (like temperature), we measure the distance and square it — landing twice as far is four times as bad (that's MSE). For guessing a category (cat vs dog), we don't measure distance; we ask "how surprised are you by the right answer?" If you said "99% dog" and it was a dog, tiny surprise → tiny loss. If you said "1% dog" and it was a dog, huge surprise → huge loss (that's cross-entropy). Training just means nudging your throws to make the loss shrink.
Dekho, loss function ka matlab simple hai: model ne prediction ki, aur hum ek single number
nikaalte hain jo batata hai "kitna galat ho". Training ka pura kaam yahi hai — is number ko
minimize karna, kyunki gradient descent ko differentiate karne ke liye ek scalar chahiye. Bina
loss ke koi gradient nahi, koi learning nahi.
Ab do main flavours hain. MSE use hoti hai jab output ek real number ho (jaise price,
temperature). Iski root maximum likelihood hai — hum maan lete hain ki target me Gaussian noise
hai, aur us assumption ka negative log-likelihood nikaalo to bilkul (y−y^)2 nikal aata hai.
Square isliye lagate hain taaki error positive rahe aur bade errors ko zyada punish kare. Iska
gradient super clean hai: y^−y, yaani seedha error hi correction ban jaata hai.
Cross-entropy use hoti hai classification me, jaha output ek probability hota hai (softmax
ya sigmoid se). Yaha noise model Bernoulli/Categorical hai. Idea: "sahi answer par tum kitne
surprised the?" — surprise =−logp. Agar tumne sahi class ko 0.99 probability di, loss almost
zero; agar 0.01 di (confidently galat), to −log0.01=2.3, bahut bada loss. Yehi asymmetry
network ko fast seekhne par majboor karti hai.
Ek important baat: classification me MSE mat use karo. Sigmoid + MSE ka gradient
y^(1−y^) factor ki wajah se saturate ho jaata hai (zero ho jaata hai) jab model confidently
galat ho — learning ruk jaati hai. Cross-entropy woh factor cancel kar deti hai, gradient wahi magic
y^−y reh jaata hai. Yaad rakhne ka trick: real numbers → Gaussian → MSE; categories → coins →
Cross-Entropy. Dono ka gradient end me same beautiful form deta hai.