5.6.13 · HinglishMachine Learning (Aerospace Applications)

LSTM — gates, cell state

1,658 words8 min readRead in English

5.6.13 · Coding › Machine Learning (Aerospace Applications)


WHAT is an LSTM?

WHY do we need it? Aerospace mein hum cheezein lambe horizons par predict karte hain — jaise ek wing spar mein lambi vibration history se fatigue accumulation estimate karna, ya ek turbine blade ki remaining useful life (RUL) predict karna. Relevant event (ek micro-crack initiation) hazaaron timesteps pehle hua hoga. Ek plain RNN use bhool jaata hai; ek LSTM use mein hold kar sakta hai.


HOW it works — the four computations

Har timestep par hum previous output aur current input ko concatenate karte hain: . Sare gates is vector ke affine maps hain jo ek squashing function se guzarti hain.

Gates ke liye sigmoid kyun? ek valve opening fraction ki tarah kaam karta hai: = puri tarah band (block), = puri tarah khula (pass). Candidate ke liye tanh kyun? likhne wali value ko positive ya negative hone deta hai, zero par centered — signed features ke liye acha hai.


DERIVATION — why the cell update kills vanishing gradients

Chalo scratch se derive karte hain ki gradients ko survive karne mein kyun help karta hai.

Step 1 — the RNN problem. Ek plain RNN mein, . steps mein backprop Jacobians ko multiply karta hai: Yeh step kyun? Timesteps mein chain rule. Har factor mein hai aur aksar hoti hai, toh product exponentially — gradients vanish ho jaate hain.

Step 2 — the LSTM cell path. Sirf line ke saath cell recurrence ka derivative lo: Yeh step kyun? mein, baaki terms ko inputs maan kar, direct partial sirf hai — koi weight matrix nahi, koi tanh' nahi, sirf ek elementwise gate.

Step 3 — chain along the cell path. Yeh kyun matter karta hai: agar forget gate ke paas rehta hai (network choose karta hai yaad rakhna), toh product ke paas rehta hai — gradient bina kisi kami ke peeche flow karta hai. LSTM seekh sakta hai highway ko khula rakhna. Yahi constant error carousel hai.


Figure — LSTM — gates, cell state

Worked Example 1 — one scalar timestep

Scalar states lo. Diya gaya , aur pre-activations is tarah chosen ki .

  • Cell: . Kyun? Purani memory ka 90% rakho, naye candidate ka 80% add karo.
  • Output: . Kyun? (Squashed) cell content ka 60% read out karo.

Worked Example 2 — "remember forever"

Maano task ko par dekhi gayi ek value 1000 steps tak store karni hai. Agar network set kare saare ke liye, toh Yeh step kyun? Forget gate poori tarah khula aur input gate band ke saath, memory perfectly copy hoti hai — ek plain RNN literally yeh bina exploding/vanishing ke nahi kar sakta.

Worked Example 3 — aerospace framing

Vibration sensor stream ek LSTM ko feed karta hai jo bearing RUL predict karta hai. par ek rare high-amplitude spike ko par prediction par influence karna chahiye. Training push karta hai (spike ko mein write karo), phir baad mein (use hold karo), aur (forecasting karte waqt read out karo). Kyun? Gates learned data-dependent switches hain — gradient descent is routing ko automatically discover karta hai.


Common Mistakes


Flashcards

Ek LSTM timesteps ke beech kon se do states carry karta hai?
Cell state (long-term) aur hidden state (short-term / output).
Cell-state update equation likho.
.
kya hai aur yeh kyun matter karta hai?
Yeh ke barabar hai; bina kisi weight matrix ya tanh' ke yeh gradients ko undiminished flow karne deta hai jab ho (constant error carousel).
Gates ke liye sigmoid lekin candidate ke liye tanh kyun?
Sigmoid ek fractional valve ki tarah kaam karta hai; tanh signed, zero-centered candidate values allow karta hai.
Output gate kya karta hai?
— control karta hai ki (squashed) cell state ka kitna hissa hidden/output vector ke roop mein read out hota hai.
Forget-gate bias ko positive kyun initialize karte hain?
Taaki initially ho → network default se yaad rakhe aur early training mein gradients survive karein.
Ek plain RNN mein gradients kyun vanish hote hain?
; factors exponentially tak multiply ho jaate hain.
set karne se kya behaviour milta hai?
— memory perfectly copy hoti hai, ek value ko indefinitely store karte hue.

Recall Feynman: 12-saal ke bacche ko samjhao

Ek khilone ki train sochao jo ek note lekar track par chal rahi hai. Har station par teen gatekeepers hain jinke paas dials hain. Gatekeeper 1 (forget) decide karta hai purane note ka kitna hissa erase karna hai. Gatekeeper 2 (input) decide karta hai naye note ka kitna hissa add karna hai. Gatekeeper 3 (output) decide karta hai abhi note ka kitna hissa zor se padhna hai. Kyunki train bas note ko track par carry karti hai (scratch se rewrite nahi karti), woh ek important message bahut lambe time tak rakh sakti hai — isliye LSTM un cheezein yaad rakhta hai jo ek normal robot brain bhool jaata hai.


Connections

Concept Map

suffers from

overwrites

adds

conveyor belt avoids

maintains

feeds

forget f_t

input i_t

written via i_t

via output o_t

derivative equals f_t

enables

Vanilla RNN

Vanishing gradient

Hidden state h_t

LSTM unit

Cell state c_t

Concat h_t-1 and x_t

Sigmoid gates

Cell update c_t

Candidate tanh c_t

Gradient flow preserved

Long-horizon RUL and fatigue