3.2.13 · AI-ML › Training Deep Networks
Intuition Ek hi saans mein core idea
Ek neural network sirf wahi jaanta hai jo usne dekha ho. Agar tumhare dataset mein 10,000 billi ki photos hain, toh network unhi exact 10,000 billiyon ko seekhta hai. Data augmentation artificially tumhara dataset expand karta hai existing samples ki label-preserving transformations banake — ek ulti billi phir bhi billi hai — taaki model zyada variety dekhe bina tumhare zyada data collect kiye.
Kyun ke baare mein sochne ke do tarike
View 1 — Zyada data. Har transformation ek "muft" naya training example hai. Flips, crops, aur color-jitters par train kiya hua model effectively laakhon variants dekhta hai.
View 2 — Invariances inject karna (gehri wajah). Tum network ko bata rahe ho ki kin changes se jawab nahi badalna chahiye . 15° ghumi billi phir bhi billi hai → network ko rotation ke liye invariant hone par majboor kiya jaata hai. Yeh un functions ki space ko chhota karta hai jo woh fit kar sakta hai, jo exactly regularization hai.
Definition Data augmentation
Ek set of transformations T jo training inputs x par (aur kabhi kabhi labels y par bhi) apply hoti hain taaki semantic label preserve ho:
T ( x ) ∼ p data , label ( T ( x )) = label ( x )
Training ke dauran minimize kiya gaya augmented risk transformations par ek expectation hoti hai.
Intuition Yeh overfitting kyun reduce karta hai (Feynman-level)
Overfitting = exact pixels yaad karna. Agar wohi image har epoch mein alag dikhti hai, toh yaad karna impossible ho jaata hai; network ko aisi features seekhni padti hain jo transformations ke baad bhi survive karti hain — edges, shapes, semantics.
Definition Geometric transforms
Flip / rotate / crop / scale / translate. Pose aur framing ke baare mein invariance encode karta hai.
⚠️ Billiyon ke liye horizontal flip theek hai; vertical flip digit "6"→"9" aur text tod deta hai . Wahi transforms choose karo jinka invariance tumhare domain ke liye sach ho .
Definition Photometric transforms
Brightness, contrast, hue, saturation jitter, added noise, blur. Lighting aur sensor conditions ke baare mein invariance encode karta hai.
Definition Occlusion / erasing
Cutout / Random Erasing — ek random rectangle mask out karo. Kyun? Network ko poore object ka istemal karne par majboor karta hai, sirf ek lucky patch ka nahi (ek billi jo sirf kaan se pehchani jaaye woh tab fail ho jaayegi jab kaan chhupaaya jaaye).
Definition Mixing augmentations (label-changing!)
Yeh "label-preserving" rule ko jaanbujhkar todte hain aur labels bhi mix karte hain .
Mixup: do images aur unke one-hot labels blend karo:
x ~ = λ x i + ( 1 − λ ) x j , y ~ = λ y i + ( 1 − λ ) y j , λ ∼ Beta ( α , α )
Kyun? Classes ke beech linear behavior ko encourage karta hai → smoother decision boundaries, kam over-confidence.
CutMix: image j ka ek patch image i par paste karo; labels ko patch area λ ke anupat mein mix karo.
Worked example Worked example 2 — Mixup label
λ = 0.7 , image A = billi ( y = [ 1 , 0 ]) , image B = kutta ( y = [ 0 , 1 ]) .
y ~ = 0.7 [ 1 , 0 ] + 0.3 [ 0 , 1 ] = [ 0.7 , 0.3 ] .
Yeh step kyun? Target ab "70% billi, 30% kutta" hai, toh network ek hard, over-confident 1.0 ki jagah ek calibrated soft output seekhta hai.
Worked example Worked example 3 — CutMix area ratio
Ek 64 × 64 kuttay ka patch ek 224 × 224 billi par paste karo.
λ cat = 1 − 224 ⋅ 224 64 ⋅ 64 = 1 − 50176 4096 ≈ 0.918 .
Label = [ 0.918 , 0.082 ] .
Yeh step kyun? Label ko area ke hisaab se mix karna supervision ko consistent rakhta hai iss baat ke saath ki kitna object actually visible hai.
Common mistake "Zyada augmentation hamesha better hoti hai."
Kyun sahi lagta hai: zyada variety → kam overfitting, hai na? Galti: bahut aggressive augmentation images ko unrecognizable bana sakti hai ya unhe sahi data distribution se door dhakkel sakti hai, toh model garbage par apni capacity barbaad karta hai ya underfit karta hai. Fix: augmentation strength tune karo; validation accuracy iska guide honi chahiye. Extreme augment → training loss zyada rahti hai.
Common mistake "Validation/test set par bhi augmentation lagao."
Kyun sahi lagta hai: consistency — sabhi data ke saath ek jaisa vyavhaar karo. Galti: tum distorted data par evaluate karte ho, toh metrics real deployment ko reflect nahi karte. Fix: sirf training set par augment karo. (Exception: test-time augmentation deliberately augments par predictions average karta hai — yeh ek alag technique hai.)
Common mistake "Kuch bhi flip karo — yeh bas ek mirror hai."
Kyun sahi lagta hai: flips clearly preserve karte hain "ek billi billi hai." Galti: text, digits, medical laterality (left vs right lung), road signs ke liye, ek flip label badal deta hai. Fix: sirf wahi invariances use karo jo tumhare domain mein sach hain .
Common mistake "Augmented images ek baar precompute karo aur save karo."
Kyun sahi lagta hai: har epoch mein compute bachata hai. Galti: tumhare paas ek fixed enlarged dataset aa jaata hai, Step 3 wali per-epoch novelty kho jaati hai. Fix: har epoch mein augmentation on-the-fly apply karo taaki har epoch fresh t i sample kare.
Recall Scroll karne se pehle khud test karo
Augmented risk likho aur batao ki ek batch mein ek transform sample karna valid kyun hai.
Ek aisa case do jahan horizontal flip label destroy kar de.
Mixup mein, class 0 aur class 1 ke beech λ = 0.4 ke liye mixed label kya hai?
Augmentation on-the-fly kyun lagani chahiye precompute ki jagah?
Cutout better feature use kyun force karta hai?
Recall Feynman: ek 12-saal ke bachche ko samjhao
Socho tum apne dost ko photos se pehchanna seekh rahe ho. Agar tumne sirf ek photo dekhi ho, toh jab woh topi pehne ya andhere mein khadi ho toh tum confuse ho jaoge. Toh hum photo ki bahut saari copies banate hain — ulti, zyada roshan, zoom ki hui, ek kona dhaka hua — aur sab padhte hain. Ab tum apni dost ko kahin bhi pehchan lete ho, kisi bhi roshni mein, chahe uska chehra thoda chhupaaya hua ho. Yahi data augmentation hai: saste "trick photos" banana taaki computer chhoti chhoti changes se bewaqoof na bane.
Mnemonic Families yaad rakho
"G-P-O-M" se
G eometric (flip/crop/rotate) · P hotometric (color/noise) · O cclusion (cutout/erase) · M ixing (mixup/cutmix).
"G ood P hotos O ften M ix."
Data augmentation kya hai? Training data par label-preserving (ya label-mixing) transformations apply karna taaki variety badhe aur desired invariances inject ho, regularization ki tarah kaam karta hai.
Augmented empirical risk likho. N 1 ∑ i E t ∼ P ( T ) [ ℓ ( f θ ( t ( x i )) , y i )]
SGD ek minibatch mein ek transform kyun use kar sakta hai? Kyunki ℓ ( f θ ( t i ( x i )) , y i ) jahan t i ∼ P ( T ) hai, expected augmented loss ka unbiased Monte-Carlo estimate hai.
Augmentation kyun kaam karta hai ke do mental models? (1) Zyada effective training data; (2) invariances inject karna = hypothesis space chhota karna = regularization.
Ek aisa example do jahan horizontal flip label tod de. Text/digits (6↔9), road signs, medical left/right laterality.
Mixup formula inputs aur labels ke liye? x ~ = λ x i + ( 1 − λ ) x j , y ~ = λ y i + ( 1 − λ ) y j , λ ∼ Beta ( α , α ) .
CutMix labels kiske hisaab se mix karta hai? Pasted patch ke area fraction λ ke anupat mein.
Cutout/Random Erasing kyun madad karta hai? Yeh object ka hissa chhupa deta hai, model ko poore object ka istemal karne par majboor karta hai na ki sirf ek discriminative patch ka.
Kya test set par augment karna chahiye? Nahi (sirf train par), jab tak deliberately test-time augmentation nahi kar rahe jo augments par predictions average karta hai.
Precompute-once augmentation on-the-fly se worse kyun hai? Precomputing ek finite enlarged set fix kar deta hai; on-the-fly har epoch mein fresh transforms deta hai, memorization rok ke.
Steel-man: "zyada augmentation hamesha better" galat kyun hai? Bahut strong augments data ko true distribution se door kar dete hain → underfitting; strength ko validation ke through tune karna padta hai.
Mixup label λ=0.4 ke liye class0 aur class1 ke beech? [ 0.4 , 0.6 ] .
Regularization — augmentation ek implicit regularizer hai.
Overfitting and Generalization — woh problem jise augmentation tackle karta hai.
Convolutional Neural Networks — translation invariance random crops ke saath pair hoti hai.
Empirical Risk Minimization — augmented ERM ise extend karta hai.
Batch Normalization & Dropout — complementary regularizers.
Transfer Learning — chhote fine-tuning sets ke saath augmentation khaaskar zaroori hai.
Beta Distribution — Mixup coefficient λ sample karta hai.
Label-preserving transforms
Augmented ERM expectation
Unbiased estimator per batch
Vertical flip breaks 6 to 9