03

Gates over time

Keep the six events fixed. Change one multiplier and trace the consequence.

A controlled coordinate—not a trained model

This lab directly prescribes one scalar coordinate, starting from c0=h0=0c_0=h_0=0. The candidate sequence is +1, 0, 0, −1, 0, 0. The first input gate is 1; the counter-cue's input gate is the control ww; the others are zero. The same selected ff and oo apply at all six steps.

There are no trained weights, text encoder, or learning algorithm here. Exact gate values 0 and 1, and candidates −1 and 1, are idealized limiting values chosen to make retention and cancellation inspectable—not finite mathematical sigmoid/tanh outputs.

Before changing anything, predict: if you set output exposure to zero, will the cell state disappear too? Then compare the cell and hidden traces. The step control selects a calculation to inspect; it does not change the trajectory.

MEMORY LAB

Keep. Write. Expose.

One scalar cell · prescribed gates · no trained network

Make a prediction (optional)
If output o becomes zero, must cell c become zero?

Cell memory and hidden output across six stepsPrescribed-gate toy. Solid circle series is cell c; dashed square series is hidden h. Coincident marks combine a circle and square. Selected step 4, counter-cue, c=0.729, h=0.622. All steps appear in the table, rounded to three decimals. Lines connect discrete computed states, not measurements between steps.10-10123456step tt = 4Cell memory and hidden output across six stepsPrescribed-gate toy. Solid circle series is cell c; dashed square series is hidden h. Coincident marks combine a circle and square. Selected step 4, counter-cue, c=0.729, h=0.622. All steps appear in the table, rounded to three decimals. Lines connect discrete computed states, not measurements between steps.10-10123456step tt = 4

● Cell c□ Hidden h

Fixed scale for this toy. Overlapping circle/square marks mean the states coincide. Select a step below.

Step 4 · counter-cue Previous cell 0.810 · candidate -1.000

0.729retained0.9 × 0.810
+
0.000written0.0 × (-1.000)
=
0.729new cell cstored state

Hidden h = 1.0 × tanh(0.729) = 0.622

The counter-cue proposes −1. The input multiplier admits 0.0 of that negative write; it is added to retained memory.

Step 4: cell 0.729, hidden 0.622. Final cell 0.590, hidden 0.530. The counter-cue is blocked; the original cue is only scaled by retention. Changing output leaves c unchanged here because future gates are prescribed independently of h.

Gates and candidates are hand-set, independently of h. Exact gate 0/1 and candidate ±1 are limiting idealizations, not finite-real sigmoid/tanh values. This is forward arithmetic, not training or a measured gradient. Calculations use full precision; visible values round to three decimals. A learned LSTM can feed h into future gates, unlike this experiment.

Inspect every step's values
Derived toy states · displayed to three decimals
Step / eventgich
1 · cue1.0001.0001.0000.762
2 · gap0.0000.0000.9000.716
3 · gap0.0000.0000.8100.670
4 · counter-cue ← inspecting-1.0000.0000.7290.622
5 · gap0.0000.0000.6560.576
6 · read0.0000.0000.5900.530
Static comparisons: keep, fade, cancel, hide

Same prescribed sequence; different multipliers. These final-step comparisons remain available without scripts.

Derived final state at step 6
Casefi₄oc₆h₆
Keep the cue1.00.01.01.0000.762
Let it fade0.50.01.00.0310.031
Admit counter-cue1.01.01.00.0000.000
Close output1.00.00.01.0000.000

Closing output hides the cell from h; it does not erase the toy cell. Admitting the equal, opposite counter-cue at f=1 cancels the cell rather than proving that nothing was written.

Follow the first write

At the defaults, f=0.9f=0.9, w=0w=0, and o=1o=1. The first write makes c1=1c_1=1. Each later step keeps nine tenths of what remains, with no new write. At the selected fourth step:

c4=0.93=0.729c_4=0.9^3=0.729

There are three transitions after the first write—not four. Lower ff and watch that contribution fade faster. Set f=1f=1 to see idealized perfect retention in this fixed-gate example. Neither curve measures a trained model's ability to remember a task.

A write can oppose what is already there

With f=1f=1, raise ww from 0 to 1. Step 4 admits the candidate −1: the retained +1 and the written −1 cancel. The resulting zero does not mean that nothing was written.

Now set w=0w=0 and lower oo to zero. Every hidden value becomes zero, while the cell retains the cue. In this toy, future gates and candidates are prescribed independently of hidden state, so the entire cell trajectory is unchanged. A learned LSTM need not preserve that future invariance.

Track both contributions to the final step

The first write crosses five subsequent transitions to reach step 6. The negative write at step 4 crosses two. Their contributions add:

c6=f5−wf2c_6=f^5-wf^2
h6=otanh⁡(c6)h_6=o\tanh(c_6)

With the defaults, c6=0.59049c_6=0.59049. The display rounds to three decimals; calculations use the unrounded values. This is an exact decomposition of the prescribed sequence, not a general formula for every LSTM input.

Repeated multiplication explains forward retention. A related question appears during training: can a later error still influence an earlier computation?