can you tell me why segment per cell is 128?

A cell has full connections with other cell, so my thinking is a cell has 2048x32 segments.

# Cell segments vs synapses

**Rodi**#1

HTM Cheat Sheet

HTM School 12: Temporal Memory Part 2

**rhyolight**#2

You can think of segments as roughly equivalent to dendrites, in this case distal dendrites. So a cell can have 128 distal dendrites, any one of which could depolarize the cell. Each segment can have many synapses (in this case 128). So the total **max** synapses per cell would be 128x128.

**sheiser1**#3

Each cell is actually not connected to all other cells in the HTM region, rather they each start out with no connections to other cells and form them through learning. When input ‘B’ arrives after input ‘A’, the cells that activate each form a dendrite segment of synapses, each synapse connecting to a cell that was active for the prior input (‘A’). That segment is now detecting for that pattern (‘A’ --> ‘B’), and will cause those ‘B’-cells to become predictive when the ‘A’-cells activate, recognizing their place in that sequential context.

If a different pattern occurs involving ‘B’ (say ‘C’ --> ‘B’) a different set of cells representing ‘B’ will activate, forming dendrite segments of synapses linked to the ‘C’-cells from the prior time step. Dendrite segments are significant because (among other reasons) they enable the same cells to detect many different patterns. The same set of ‘B’-cells from the ‘A’ --> ‘B’ sequence could learn to predict ‘B’ from the separate ‘B’ --> ‘C’ sequence, with separate dendrite segments linking to ‘C’-cells. New segments are only formed when the current input doesn’t match well to any existing segments, and each cell can form up to 128 segments.

**Rodi**#4

Thank you so much.

I understood that a cell is not connected to all other cell. a cell has maximum is 128 distal segments and 128 synapses per a distal segment mean that a distal segment has 128 connections with 128 other cells. is it right?. if it is right, can I ask you more questions?. we have 2048 colums, 32 cells per colums, and 40 cells active at the time. so to predict active cell of B from A. we will have 128 segment and 128 synapses per segment connect to 128 randomly other cell of A (we have total 2048x32 cells). it is so large, so how can we know sum of 128 synapse from 128 cells of A is above segment threshod is 15 or not . if sum of 128 synapses from other cells is above 15, we will set this distal segment is active, so this cell of B is predictive cell.

**Rodi**#5

can you help me more?. I read this sentences from paper its name is Why Neurons Have Thousands of Synapses, a Theory of Sequence Memory in Neocortex

so D(d,i,j). D is distal segment, and max d is 128. and D(d,i,j) has connected to all other cells, so why D(d,i,j) has size is M,N with M is number cells per column and N is number of columns. so it cant be 128 synapties.

hope you can help me.

Thank you.

**sheiser1**#6

If a cell’s distal segment has 128 synapses on it each will connect to a different cell that was active in the prior time step, so it is potentially connected to 128 other cells yes. The ‘B’-cells that become predictive when input ‘A’ arrives are predicted because they have at least one segment with a large proportion of its synapses connected to active cells (representing ‘A’ in this case).

Remember that each cell begins with 0 distal segments and forms them as needed for new contexts, so at a given time most cells likely have closer to a handful or 2 of segments than the maximum possible 128. When an unfamiliar pattern occurs, say ‘B’ arrives when it was not predicted, the set of cells that become active to represent this new ‘B’ are each chosen because they have the least number of distal segments of all cells in their SP column. This means that you’ll wind up with many ‘B’-cells that have a few segments, not a few cells that are packed with 128 segments.

At each time step, each cell monitors all of its segments to see if any have more than 15 active synapses. They don’t sum the active synapses from all their segments, only within each segment. If one of a cell’s segments has more than 15 active synapses then that segment is considered active and the cell is put into the *predictive* state. D(d,i,j) represents the d’th segment on the i’th cell in the j’th column, and has an NxM matrix containing its permanence values to all other cells in the region. However this matrix is extremely sparse, so the VAST majority of its values will be 0. In fact there will only be s (128) non-0 values, since that’s how many synapses are on each segment.

Overall I’d highly recommend carefully watching Matt’s HTM school episodes on Temporal Memory and also re-reading the Temporal Memory pseudocode in the BAMIbook online. I actually re-wrote the pseudocode into my own notebook, which helped me internalize how it works. Here are the links below:

**rhyolight**#7

I would not make any assumptions about how many different cells each dendrite connects to. The pyramidal neuron should not care where it’s connections originate. Maybe there are many connections between two cells? I’m not sure, but I would not make that assumption.

In practice, cells don’t usually grow so many segments. In simple pattern examples, there are usually no more than 1 segment per cell. The noisier the input data, the more segments end up getting created.

**Rodi**#8

Thank you for helping me.

I watched video. And at minute 11:00, I see one cell of C# is predicted from all active cells from E. and magenta color lines connect to blue cell is show as a segment of blue cell. so a blue cell of C# has only one segment. and this segment has many synapses connect to other cells. I think this blue cell connect to all other cell in region. that why segment D(d,i,j) has MxN synapses.thus, when E arrives, active cells of E can make blue cell become predictive state. so where is 2nd segment and 128th segment of blue cell. can you give me other sequence, that can show 2nd segment of blue cell.

this is my example.

sequence of video is F# E C# A. so blue cell of C# has a segment connect to other cells in region. when E come, blue cell will be predicted.

so if I have other sequence G# H D# M. and one of cells D# has same position of blue cell of C#. so this cell of D# has a segment connect to other cells of H.

so I think, at position of blue cell, this blue cell can be predicted from 2 segments, one from E, and other from H.

if E arrives, segment of C# and E will above threshod, so blue cell will be predicted

if H arrives. segment of D# and H will above threshod, so blue cell will be predicted

same for other sequence, i will have 128 segments for cell at position of blue cell.

is it right?. if my thinking is wrong, can you tell me more clearly. actually, I read paper and watch video many times, but concept distal segment and synaptic in this case make me confuse.

Hope your help for me.

Thank you.

**Rodi**#9

and this is what i read from a thesis.

I see cells A, cells B, and cells C to make predict to any cell (maybe one of cells of D).

so what is cells A, cells B, cells C in this case. is it from some sequences like this

sequence #1 A D …

sequence #2 B D …

sequence #3 C D …

**rhyolight**#10

In this example, the cell only has one segment. There is no 2nd segment or 128th segment. If the input over time is very noisy and random, the cells will grow lots of segments as new unique input is perceived. But in this simple case where the input repeats regularly without noise, there is no need to grow more segments.

**Rodi**#11

In this case, distal dendrite segments A,B, C are noise of a input (ex E). so when E has noise (A,B,C) it will connect to a cell of D to predict that cell of D.

and without noise, just have one distal segment that is used to predict D. that is my understanding. is it right?

hope your help for me

Thank you.

**rhyolight**#15

There is a difference between the creation of a segment, a segment growing synapses, and the synapse permanence increasing. I don’ know the exact answer to your question, but @mrcslws or @scott probably will.

**Niki**#16

Hi @sheiser1

I had a question about matrix D(d,i,j), I saw you explained it very well. You mentioned “D(d,i,j) represents the d’th segment on the i’th cell in the j’th column, and has an NxM matrix containing its permanence values to all other cells in the region.” this means for example, for cell 1 in column 1, we will have:

D(1,1,1),D(2,1,1),…,D(128,1,1)

That is correct?

**sheiser1**#17

That cell in that column could have as many as 128 segments yes, though it would take a LOT of noise in the data for that many segments to be created. If I’m correct it would mean that all other cells in that column also had grown at least 127 out of 128 possible segments.

I think the best way to totally understand this is to look at the temporal memory pseudo code (link below). As you’ll see a new segment is only grown when no other segment on any cell in that column remotely matches the prior input. When this happens the columns bursts (all cells activate), and the cell that is chosen to grow a new segment on (known as the ‘learning cell’) is the cell in the column with the *fewest* existing segments. This is to *avoid* having too many segments on any one cell, since this increases the number of patterns that the cell is apart of and thus increases the chance for false positive depolarization of the cell (falsely becoming predictive). So for a cell to grow a 128th cell it would mean that all other cells in its columns already have 127+ segments on them, which would mean the data was really really noisy.

**Rodi**#18

Hi @sheiser1

Can I ask you one question?.

I just learn simple sequence, and just one segment on a cell. So what happen when the first time I learn sequence. does it burst all cell, but how about fewest segment. is this case I choose random cell active. and what about permence on synapse for first time I learn. is it inital permence 0.21, so I will have matching segment, just one, so that is bestmachingsegment too. if so how about the second time I learn sequence( ex ABC).

Hope your help for me.

Thank you.

**sheiser1**#20

Hey @Rodi,

I think you’ve got it right. The first time you see a sequence all columns of cells activated by the spatial pooler will burst (since none were predicted). When a column bursts a new segment will be formed on the cell with the fewest amount of segments, using random tiebreak (this is a random cell on the first sequence since they’re all tied with 0 segments at that point). Whichever cell is chosen to grow the new segment (the ‘learning cell’), that segment consists of synapses which each connect to a cell active in the prior time step. Each of these synapses has a permanence value to determine if the synapse is formed.

Setting the initial permanence (0.21) above the connection threshold (0.2) means that the system will learn quickly to predict a pattern after seeing it just one time, as the permanence will only drop below 0.2 if the pattern was wrongly predicted. Therefor if the sequence you’ve just seen for the first time repeats no new segments are needed since the columns won’t burst, the cells that grew the first synapses will become correctly predictive, and the permanence values of the synapses on those predictive segments will be incremented and reinforce the pattern.