This post describes a subtle flaw in the Temporal Memory algorithm and suggests a way to fix it.
When the temporal memory (TM) encounters a sequence that it has never seen before, it assigns a unique set of cells to represent each element of the sequence. These cells grow new synapses so that in the future the TM will recognize the sequence. Under normal conditions, once a cell starts growing synapses it becomes a permanent part of the sequence and the cell remains active for as long as that element of the sequence is in the TM’s input.
Consider when the TM creates a new segment and populates it with synapses from the previously active cells. Assume that the input is changing slowly. If the input is changing slowly then the active cells will also change slowly. On the next time-step after we create the new segment: most of our new synapses will activate again because most of the previously active cells are still active. And then the segment will activate and grow even more synapses to keep up with the slowly changing activity. The active cells grow synapses in an all-to-all pattern to form a clique. The segment learns to detect both the previous element of the sequence as well as the element that it is part of.
In this way, the TM can recognize sequences even if you speed them up or slow them down. You can even pause and resume the sequence and the TM will retain its state while you give it a constant input.
Figure 1. A Temporal Memory is given the same waveform at different speeds. In all three cases the cellular activity is identical at corresponding points in the waveform.
However if the input moves very fast, then mini-columns are only active for one time-step and so the co-active cells do not grow synapses between each other. They learn to recognize the previous element of the sequence but not the the element that they are part of.
Consider a very fast moving input that suddenly stops and becomes stationary, for example a square wave. On the first time-step of the stationary input, the TM assigns winner cells to represent the new element and grows new synapses from the previous winner cells. However the previously active cells will not activate again because they correspond with the fast moving part of the sequence. On the second time-step of the stationary input none of the segments grown on the first time-step will activate and the mini-column will burst. Then the TM algorithm chooses all new winner cells and grows new synapses from the previous time-step’s now all inactive winner cells. In this situation the TM is incapable of creating stable activity. The exact sequence of events is outlined below:
Step 0) Move the TM’s input quickly and unpredictably,
or reset the TM. Then give the TM a constant input. In all of the following steps the same mini-columns are active, and patterns refer to subsets of the cells in those mini-columns.
Step 1) Burst, new winners are pattern “A”.
Step 2) Burst, new winners are pattern “B”, grow new synapses from A → B.
Step 3) Burst, detect matching segments from A → B and reinforce them, winners are pattern “B”.
Step 4) Activate pattern “B”.
Step 5) Burst, new winners “C”, grow new synapses from B → C.
Step 6) Activate pattern “B”.
Step 7) Burst, detect matching segments from B → C and reinforce them, winners C
Step 8) Activate B & C
Step 9) Activate C (as a result of the synapses from B → C)
Step 10) Burst, new winners D, grow new synapses from C → D
Step 11) Activate B & C
Step 12) Activate C (as a result of the synapses from B → C)
Step 13) Burst, detect matching segments from C → D and reinforce them, winners D
Step 14) Activate B & C & D
Step 15) Activate C & D
Step 15) Activate D
Step 16) Burst …
And the cycle continues until all of the cells in the active mini-columns are incorporated into the pattern, at which point the pattern becomes stable (but highly undesireable).
The way to fix this problem is to change how the TM algorithm chooses a new winner cell when a mini-column bursts. Instead of simply making an arbitrary cell into the winner cell, the TM should check if in the previous time-step there was a winner cell in that mini-column and use it if possible.
This solves the static input problem without significantly altering the TM algorithm. It is fast to compute and biologically plausible.