Confusion in synapse count in TM


I am looking at the pseudocode of TM in BAMI. I have this confusion in line 22 about the meaning of numActivePotentialSynapses. Does it return the number of both ACTIVE synapses and POTENTIAL synapses connecting to active cells in previous timestep?

If thats the case, then we cannot say that the segment will definitely have SYNAPSE_SAMPLE_SIZE active synapses after growing segments since potential synapses are even part of the SYNAPSE_SAMPLE_SIZE.
My argument is that line 22 should be just newSynapseCount = (SYNAPSE_SAMPLE_SIZE - 23. numActiveSynapses(t-1, segment))

Please correct me if I am wrong.

1 Like

The potential synapses would eventually learn to make a connection.
So in the end, the number of active synapses would be approximately SYNAPSE_SAMPLE_SIZE.

1 Like

This is the number of already-occupied synapses on a segment. All segments have a maximum number of synapses they can grow at one time (SYNAPSE_SAMPLE_SIZE). So the number of previouslyActiveCells that a segment will connect to this time (newSynapseCount) is max - existing (or SYNAPSE_SAMPLE_SIZE - numActivePotentialSynapses).

Thanks. I understood. Does the potential synapse in ActivePotentialSynapse point to only the potential synapses connecting to the active cells of the previous timestep or it can include any potential synapse? The latter seem to be the case from your reply. Just want to confirm. The term active confuses me here.

1 Like

Right good question. For a segment the numActivePotentialSynapses is the number of synapses who’s pre-synaptic cells are active at the given tilmestep (t-1) as shown in line 23.

Here’s how numActivePotentialSynapses is populated from the pseudocode:

1 Like

Understood. Thanks. In that case, should line 22 be

newSynapseCount = (SYNAPSE_SAMPLE_SIZE - numActiveConnectedSynapses -numActivePotentialSynapses(t-1, segment))

We should even subtract the connected and potential synapses to get the number of new synapses to grow…right? The definition of SYNAPSE_SAMPLE_SIZE says the desired number of active synapses

1 Like

No, see lines 63 and 64. Variable “numActivePotential” is incremented whether or not the synapse is above the connected permanence. Thus, this count already includes the active connected synapses (no need to subtract that number twice).

4 Likes

Thanks for the clarification. It helped me understand better. One final query:


Suppose a column (say A) bursts at time t. All the cells in the column are set as active. Assuming the algorithm is running for time (t), suppose that another column (say B) bursts in the next timestep(t+1). Then, the learning segment’s synapses in time t+1 will increase the permanence values to all the active cells in column A. But since the winner cell at time (t) in column A is the representation of the input, shouldnt learning segment at time t+1 just increase permanence values to the winner cell instead of all active cells in column A?
I mean line 41 should be
41. if synapse.presynapticCell in winnerCell(t-1). Please clarify.

Good question. This shouldn’t be a problem in practice, since the learning segment won’t actually have synapses to all the cells in any column. Within the growNewSegment function, new synapses are only grown to prevWinnerCells which are a subset of prevActiveCells. This level of detail isn’t in this pseudocode, but you can find it here in the _growSynapses classmethod:

1 Like

Not sure if you are interested in differences between implementations @baymaxx, but this is one detail that some implementations differ on (for example Etaler). There is an advantage of connecting with any of the previously active cells rather than only the winner cells – it allows repeating sequences to eventually stabilize with enough iterations. The drawback is that it can lead to more ambiguity, so when implementing it this way, you would probably also want to implement a decay of unused synapses over time.

4 Likes

Hi!

I had the same question as @baymaxx and I ended up in this thread. But I still have another question. If numActivePotentialSynapses is the number of synapses (independently of their permanence value) that are connected with active cells (as can be seen in lines 58-64), then, couldn’t the number of synapses in a segment grow up to values larger than SYNAPSE_SAMPLE_SIZE?

I understand that SYNAPSE_SAMPLE_SIZE is the maximum number of synapses that a segment my have (am I wrong?), but if in lines 22-23 you only count the synapses which are connected to active cells in t-1, your newSynapseCount value, added to the current number of synapses in the segment, could easily be bigger than SYNAPSE_SAMPLE_SIZE. And in that case, SYNAPSE_SAMPLE_SIZE will not be the maximum number of synapses in a segment.

Another minor question is about line 63:
if synapse.permanence >= 0 then

How could a permanence be less than 0? I think this line doesn’t really add anything (but a bit of confussion). Am I right?

Thanks a lot.

EDIT: I have been checking the code at https://github.com/numenta/nupic.core/blob/master/src/nupic/algorithms/TemporalMemory.cpp and apparently, the value of SYNAPSE_SAMPLE_SIZE seems to be equivalente to maxNewSynapseCount, which is a limit to the number of synapses that might be added to a segment in a single timestep. In the code there is another variable, maxSynapsesPerSegment, which seems to be the overal highest number of synapses that a segment can contain (which does not appear in the pseudocode). So, when new synapses are grown in a segment, there are several limits:

  • The value of maxSynapsesPerSegment, which cannot be exceeded at any circumstance, and marks the highest ever number of synapses a distal dendritic segment can have.
  • The value of maxNewSynapseCount (equivalent to the SYNAPSE_SAMPLE_SIZE of the pseudocode), which is the maximum number of synapses connected to active cells that a segment might have in order to proceed with the synapsis grow. If a winner cell has at the moment of synapsis grow a lower number of synapses connected to active cells, then it can proceed to the addition of new synapses so that after the synapsis grow it will have at most SYNAPSE_SAMPLE_SIZE synapses connected to active cells.
  • As all the synapses are connected to winner cells, the number of winner cells also might limit the total number of new synapses created, especially since a segment can only have a single sinapsis to a given cell.

I would highly appreciate if somebody could check that I got it right.

1 Like

Yes correct, this value isn’t there in the pseudocode though it is involved.

Right on all counts yes, to the best of my knowledge.

maxSynapsesPerSegment → the total number of synapses a segment can ever have – so it won’t activate from an unlimited number of prior inputs.

maxNewSynapseCount → the highest number of new synapses that can be grown on a segment at any 1 time. Any WinnerCells(t-1) are added as new synapses on the segment – excluding any already there and capped by the maxSynapsesPerSegment limit.

1 Like