5.6.6 · D4 · HinglishMachine Learning (Aerospace Applications)

ExercisesNeural network fundamentals — neuron, activation functions (ReLU, sigmoid, tanh)

2,583 words12 min read↑ Read in English

5.6.6 · D4 · Coding › Machine Learning (Aerospace Applications) › Neural network fundamentals — neuron, activation functions (

Shuru karne se pehle, char objects ka ek reminder jo hum baar baar use karenge — yeh padho chahe tumhe lagta ho ki tum jaante ho, kyunki har solution isi pe lean karta hai.

Figure — Neural network fundamentals — neuron, activation functions (ReLU, sigmoid, tanh)

Upar ke blueprint ko dekho (har curve legend mein naam se labeled hai, sirf colour se nahi): ReLU ek flat floor hai phir ek ramp. Sigmoid ek gentle S hai jo aur ke beech trapped hai. Tanh ek steeper S hai jo aur ke beech trapped hai. Figure ke arrows har curve ko naam se point out karte hain. Yeh picture apne dimag mein rakho — zyaadatar L1/L2 answers sirf yeh hain ki "main kaunsi curve pe khada hoon, aur kahan?"


Level 1 — Recognition

Problem 1.1

Kaunsa activation function value output kar sakta hai? (ReLU, sigmoid, tanh mein se choose karo.)

Recall Solution 1.1

HUM KYA DEKHTE HAIN: har function ka range (possible outputs ka set).

  • ReLU output range hai — yeh kabhi negative nahi ho sakta (iska floor hai).
  • Sigmoid range hai — strictly positive, kabhi ya nahi reach karta.
  • Tanh range hai — sirf yahi zero ke neeche jaata hai.

, aur ke beech hai, isliye yeh sirf tanh se reachable hai.

YESH KAISE DIKHTA HAI: figure mein, sirf tanh curve (legend mein labeled) kabhi horizontal axis ke neeche jaati hai.

Problem 1.2

Ek 12-layer network ki hidden layer mein ek neuron ko aisi activation chahiye jiska derivative positive inputs ke liye signals ko shrink na kare. Use naam do aur uska poora derivative do (negative branch aur pe convention including).

Recall Solution 1.2

ReLU. ke liye, , toh uski slope exactly hai. ke liye, , ek flat line jiska slope hai. Exactly pe dono branches ek corner pe milti hain jahan derivative truly defined nahi hai; convention se hum ise simply assign karte hain ( side ke saath group karke). Poori cheez likhte hain: Active branch pe ki slope ka matlab hai backpropagation se multiply karta hai — signal bina dimmed hue pass hota hai, isliye ReLU deep hidden layers ke liye default hai. Contrast: Vanishing and Exploding Gradients tab hota hai jab se chhoti slopes kaafi saari layers mein ek saath multiply hoti hain.


Level 2 — Application

Problem 2.1

Ek neuron ke weights , bias , inputs hain. compute karo, phir ReLU apply karo.

Recall Solution 2.1

Step 1 — weighted sum (KYA & KYUN): hum har input ko uske weight se multiply karte hain uske contribution ko score karne ke liye, phir bias nudge add karte hain. Yahan . Step 2 — activation: exactly pe ReLU: Output . Edge case note karo: ReLU curve ke corner pe baithta hai. Hamari definition se for , toh darwaza abhi abhi band hai.

Problem 2.2

ke liye, 4 decimals tak compute karo, phir identity use karke wahan derivative nikalo.

Recall Solution 2.2

Step 1: .

Step 2 (KYUN yeh identity): hum har baar scratch se differentiate nahi karna chahte; yeh identity humein abhi compute ki gayi value reuse karne deti hai. Padhna: lagbhag ki slope — pehle hi maximum se kaafi neeche. Sigmoid pe flatten (saturate) hona shuru ho rahi hai.

Problem 2.3

ke liye, compute karo aur phir compute karo use karke.

Recall Solution 2.3

Step 1: .

Step 2 (KYUN value reuse karein): sigmoid jaisa hi trick — output ko square karo aur se subtract karo. Padhna: pe tanh ka ek healthier slope () hai sigmoid ke pe wale se — yahi tanh ka "middle ke paas stronger gradient" wala advantage hai.


Level 3 — Analysis

Problem 3.1

Ek student ek "two-layer linear network" propose karta hai bina kisi activation ke: Algebraically dikhao ki yeh ek single-layer linear model ke equivalent hai, aur ek sentence mein bolo ki yeh problem kyun hai.

Recall Solution 3.1

ko mein substitute karo: aur maano. Tab jo ek single linear layer hai. Ek sentence mein problem: chahe tum kitne bhi linear layers stack karo, woh ek straight-line map mein collapse ho jaate hain, toh network sirf straight decision boundaries draw kar sakta hai aur kabhi XOR jaisa curved pattern nahi seekh sakta. Ilaaj hai layers ke beech ek non-linear insert karna.

Problem 3.2

Sigmoid ki maximum slope hai, pe hoti hai. use karke yeh maximum value prove karo.

Recall Solution 3.2

KYUN yeh method: do cheezoon ka product hai jinka sum hai: maano, toh jahan .

maximize karo: ise mein ek downward parabola ki tarah treat karo. W.r.t. iska derivative hai, pe zero. Toh peak pe hai, jo pe hota hai. Consequence: har sigmoid slope hai. 10-layer stack mein slopes ka product hai — yahi exactly vanishing gradient problem hai, aur isliye gradient descent ruk jaata hai.

Problem 3.3

Identity ko pe numerically verify karo (4 decimals), confirm karo ki dono forms agree karte hain.

Recall Solution 3.3

Left side: .

Right side: ; phir .

Dono dete hain — identity holds. Isliye tanh "ek stretched, shifted sigmoid" hai: input ko se scale karo, output ko se scale karo, aur zero pe recenter karne ke liye se neeche shift karo.


Level 4 — Synthesis

Problem 4.1

Ek control-output neuron elevator deflection ke liye weights , bias , inputs ke saath hai. Output mein hona chahiye jahan = full down, = full up. (a) Sahi activation choose karo aur justify karo. (b) Deflection compute karo.

Recall Solution 4.1

(a) Choice — KYUN tanh: output signed aur tak bounded hona chahiye. ReLU negative nahi ja sakta (toh koi "down" nahi); sigmoid mein stuck hai (woh bhi koi "down" nahi). Sirf tanh ko zero ke aas paas symmetrically cover karta hai — ek control surface ke liye perfect jo neutral se dono taraf move karti hai.

(b) Compute karo (yahan ): Padhna: elevator maximum ke lagbhag downward deflect karta hai (negative = down). Sensor Fusion in Aerospace se compare karo, jahan aisi signed outputs flight controller ko feed karti hain.

Problem 4.2

Ek anomaly detector ke output neuron ka hai. (a) Kaunsa activation output ko probability banata hai, aur kyun? (b) Woh probability compute karo, aur (c) ek truly-anomalous sample (label ) ke liye Binary Cross-Entropy Loss use karke loss compute karo.

Recall Solution 4.2

(a) Humein mein output chahiye jo "anomaly ki chance" ki tarah readable ho, toh sigmoid. ReLU output kar sakta hai (probability nahi); tanh negative ja sakta hai (negative "chance" nonsense hai).

(b) . → lagbhag confident hai ki yeh anomalous hai.

(c) Ek true anomaly (label ) ke liye, binary cross-entropy hai . Padhna: loss tiny hai kyunki network confident aur correct tha — exactly yahi hum chahte hain. Agar usne predict kiya hota, loss tak balloon ho jaata.


Level 5 — Mastery

Problem 5.1 (Dead ReLU + ek fix)

Ek neuron ReLU use karta hai. Poore dataset pe uska pre-activation hamesha hai, toh har baar. (a) Explain karo kyun gradient descent ise kabhi revive nahi kar sakta (ek "dead neuron"). (b) ReLU ko Leaky ReLU se replace karo aur pe aur compute karo. (c) Ek sentence mein explain karo ki yeh neuron ko kyun rescue karta hai.

Recall Solution 5.1

(a) ke liye ReLU ki slope hai. Backprop ke dauran, weight update us slope ke proportional hota hai, toh ka update matlab weights kabhi nahi badalte — neuron hamesha ke liye "off" pe frozen hai. Weight Initialization Strategies bhi dekho, kyunki buri init ek common cause hai.

(b) pe (negative branch, Leaky ReLU use karta hai): (c) Kyunki slope ab ki jagah hai, ek small non-zero gradient flow karta hai back, toh weights abhi bhi nudge ho sakte hain aur neuron recover ho sakta hai.

Problem 5.2 (Vanishing-gradient budget)

Tum sigmoid layers stack karte ho, aur derivatives ka best-case product hai. Sabse bada dhundho jiske liye yeh product se upar rahe (taaki learning abhi bhi hopeless na ho). Logarithms se solve karo.

Recall Solution 5.2

KYUN logs: humein ek exponent ko unstack karna hai, aur logarithm woh tool hai jo "power of" ko "multiply by" mein convert karta hai. Ab (negative) hai, toh divide karne se inequality flip ho jaati hai: Kyunki poora number hona chahiye, sabse bada allowed hai . Padhna: best case mein bhi, sirf lagbhag chaar stacked sigmoids gradients ko se upar rakhte hain — solid proof ki deep sigmoid stacks doomed hain, aur isliye hum ReLU ya Vanishing and Exploding Gradients mein techniques tak pahunchte hain. Yahi reasoning Convolutional Neural Networks design karte waqt aur Overfitting and Regularization control karte waqt aati hai.


Recall Self-test checklist

ReLU / sigmoid / tanh ka range? ::: / / . Linear layers ka stack kyun collapse hota hai? ::: Linear maps compose karke ek aur linear map deta hai. Maximum sigmoid slope aur kahan? ::: , pe hoti hai (jahan ). Signed, bounded control output ke liye kaunsi activation? ::: tanh. Probability output ke liye kaunsi? ::: sigmoid. Leaky ReLU dead neuron ko kaise revive karta hai? ::: Yeh ke liye ek small non-zero slope () deta hai toh gradients abhi bhi flow karte hain.