Write once, then keep
numeric▲△△Exact values where possible; six decimal places for non-exact numerical results.
STATEMENT
Run a scalar LSTM through three inputs and separate what the input gate writes from what the forget gate keeps.
GIVEN
A scalar cell follows (I.10.1) and (I.10.2) with every recurrent weight zero. The gates read only their biases: , , , and . The candidate is , so and . Start from and feed .
FIND
The three gate values, the candidates, all three cell and hidden states, the third cell state when instead, and the number of trainable scalars.
STRATEGY
Evaluate the gates first; they are constants here. Then apply the cell update one step at a time and read each hidden state through the output gate.
SOLUTION
Since , the gates are and . The first candidate is
and the later candidates are .
The cell update writes once and then only keeps:
The hidden states are : , and .
With the forget gate is , and . The input gate decided how much was written; the forget gate alone decided how much of it survived two silent steps.
Each of the four blocks has one input weight, one recurrent weight and one bias, so the scalar cell has trainable scalars. The plain scalar cell of I.9.B01 had three before its readout.
Answer
Gates ; candidates ; cell states ; hidden states ; with , ; twelve trainable scalars.
Check — sanity
Each hidden state is smaller than its cell state. For , , and the output gate multiplies by a further three quarters. The hidden state is a view of the cell, not a copy of it.
Check — numeric · i-10-gating-checks.py
The complete reproduction script uses only the Python standard library. From a checkout of the repository, run:
python3 scripts/snippets/i-10-gating-checks.pyIt checks all fifteen problems of the chapter. Its first line reports the cell states , , , the hidden states above and the cell state . Its second line confirms that a full two-unit LSTM backward pass matches central finite differences for every parameter.
Executed in CI. The digits above are the digits it printed.
Where this breaks
Nonzero recurrent weights make the gates depend on , so they change from step to step and the cell states are no longer a geometric sequence. The write-then-keep reading survives; the clean numbers do not.
Variation
Feed instead. The second step keeps and writes another , so and . The cell accumulates; it does not overwrite unless the forget gate is small.