4. Case Study — LSTM detection
Inside one LSTM cell: forget, write, then read
Inputs at step t
cₜ₋₁
cell memory
hₜ₋₁
hidden state
xₜ
sensors @ t
One LSTM cell · PyTorch nn.LSTM in AnomalyLSTM
gates ∈ ℝ³² · ⊙ = element-wise multiply · σ = sigmoid
[hₜ₋₁ ; xₜ]
Forget fₜ
σ(W_f [h;x] + b_f)
erase from c?
Input iₜ
σ(W_i [h;x] + b_i)
write how much?
Candidate gₜ
tanh(W_g [h;x] + b_g)
new content
Output oₜ
σ(W_o [h;x] + b_o)
expose from c?
cₜ = fₜ ⊙ cₜ₋₁ + iₜ ⊙ gₜ
keep some old · add some new
hₜ = oₜ ⊙ tanh(cₜ)
read filtered memory
cₜ → next step
long-term memory
hₜ → next step
+ class head if last
Forget (f)
Near 0 wipes old cell memory; near 1 keeps it.
After onset, drops stale “still nominal”
evidence from earlier in the window.
Input (i) + candidate (g)
i scales how much new content g is written
into c. Onset ramps in x get stored as the
fault signature builds across the 60 s.
Output (o)
Selects which parts of tanh(c) become h —
the vector the linear head reads to score
nominal vs each of the 31 anomalies.