Temporal memory sequence segment and learning cell

Hey all,
I’m building a MATLAB version of the CLA and I need help with selecting a learning cell and a sequence segment. I’m using Fergal’s updated White Paper, and there are some questions I have with regard to when a learning cell and sequence segment are chosen.

I’m generally confused by the idea of one cell in a column being labeled active and another cell being labeled learning. When a column is active but no cells predicted this occurring, the column bursts and a learning cell is chosen as the best “fit” to the current input. But when a cell does predict the current output, it is selected as active. It only is selected as learning, though, if it was previously selected as learning. Is this correct?

To be more concise, what is the complete purpose of a learning cell?

Now, if someone could then define what a sequence segment is, in a clear and thorough manner, it would be so very appreciated!

To my understanding, the sequence segment is the segment which is predicting that the very next time step is when its column will become active.


A Segment is the term representing the two kinds of Dendrites (Proximal = Dendrites connected to the input field; Distal = Dendrites connected laterally to cells in other columns) - both types can be referred to as “Segments”.

I’m not sure where you get the term “sequence segment”, can you quote the code for context?

Here is an example of a segment being selected as “learning”. It is the result of a search for the “best matching” segment, meaning the segment with the most “active” synapses or synapses whose permanence is above an “active threshold”.

Hope that helps?


I can always expect quality response from you! Thanks, and let me clear up the things that I am asking. First of all, do cells themselves have activity? They most definitely do as I have seen, though this may have been superseded in recent updates. The white paper I’m referencing is found here.
The first and seemingly only reference to sequence segments is in the pseudocode for TM. I have, though, seen this appear elsewhere; perhaps the 2011 white paper, and in various implementations coded by others. I haven’t gotten involved in htm.java yet, so I can’t see if they’re there or not (yet)! The first quote:

If the bottom-up input was predicted by any cell (i.e., its predictiveState was 1 due to a sequence segment in the previous time step), then those cells become active (lines 4-9). (Hawkins et al. 37)

This is in reference to the selection of cell activity. From the pseudocode itself:
36 if lcChosen == false then 37 I,s = getBestMatchingCell(c , t􀀀1) 38 learnState(c,i,t) = 1 39 sUpdate = getSegmentActiveSynapses ( c , i , s , t􀀀1,true) 40 sUpdate.sequenceSegment = true 41 segmentUpdateList.add (sUpdate)
The sequence segment is flagged on line 40. (This code is found on page 39.) Sequence segments are referenced in various other places, which you can see in the rest of the pseudocode. Now, if the sequence segment is not of as much use in practice, then that is fine. But I would like to be sure that this is the case!
Thanks again,

@sjgallagher2 The TM pseudocode is here (PDF). There is a lot of discussion about segments in this document.

1 Like

Moved this topic from #htm-theory:newbie-questions to #htm-theory:sequence-memory.

HI @sjgallagher2,

Thanks I appreciate that.

Cells don’t have overt activity (they don’t cause behavior), but they have state that is the effect of other activity within the algorithms. They become “polarized” (i.e. “predictive” and more biased toward firing) or they become “active” or “inactive” - and they can become marked as “winners”. (I think that’s all of their states and properties?) However, within our implementations, cells don’t actually fire; they “conceptually” fire by being marked as active.

I believe now that what you’re referring to as “sequence segment” is a distal dendritic segment or lateral segment that connects to cells in other columns. The flag:

I believe is a “marker” flag to distinguish the segment’s type as being a distal dendritic segment. I could be wrong but I bet I’m right. I’m not familiar with the pseudocode here but my knowledge of the code bases in general prompts me to come to this conclusion.

The segments are all still in use - it’s just their terminology that waivers between epics in NuPIC’s development and refinement of terms as we go along. Now I would say that the “correct” term is either “Segment” if you’re being general or either “Distal Segment” or “Distal Dendrite”.

I do know there is a clear distinction between distal and proximal segments, but that distinction is not made by the sequence segment line, I don’t believe. I’m currently running my program without the use of sequence segments because I don’t understand them yet. It seems like the htm.java code doesn’t use them either, so I’ll stay the course.

As for cell states, thank you, that helped clear things up a bit! Here’s what I’m getting at though. I’m having an issue with my code where the spatial pooler does its job well, I’ve tested it in many ways, so I’m happy with it for now. But the temporal memory is just a mess. I’ve been learning and coding at the same time and it took a while to get a working project.

The thing is, when I run the TM with the same picture over and over, only four or so cells are becoming predictive and they stay that way even when the spatial pooler changes completely. They simply keep predicting, despite never becoming active. What might be the problem here? It’s a diagnosis issue, of course, and it’s a stretch to think you could magically pick out the reason from just that description. But I figured I could ask, to give you an idea of why I’m concerned with all these things at the moment.
Thank you, once again.
Sam Gallagher

I would venture a guess to say that you are selecting the same cells during bursting to form dendrites to the currently active column cells? That would account for the same cell being predicted despite changes in the input field or SP output? The question asked by the algorithm is, “What cell was active previous to this current cell becoming active? Let me form a dendritic synapse coming from that cell to the current active cell.” <-- if that same cell is always selected then you will get the same prediction on every cycle…

I would take a look at your burst method and your bestSegment/Cell searches for some gremlins :wink:


P.S. Whatever you do don’t feed the gremlins after midnight! :stuck_out_tongue: (sorry corny movie humor)

@sjgallagher2 I would recommend looking at the updated PDF that @rhyolight pointed you to. It takes out the reference to sequence segments and also the obsolete pooling functions. Your original guess was correct, but it is not required without pooling.

If you have questions regarding the detailed logic in the sequence memory, I would recommend taking a look at this easy to read reference implementation: nupic/src/nupic/research/temporal_memory.py

It is important to use the right parameters to get decent results. I would recommend using the parameters from here (look for “tpParams”):



My apologies - that directory changed on Friday due to a commit. Please look at this file instead:

I think it would be prudent to point out that this is a community revision of an outdated document. The original repository it was forked from is now closed. More current papers are in #htm-theory:papers.