Htm.core how do you know that a column is active?

Hello,

I’m currently struggling with the groupBy method in the GorupBy.hpp file of the htm.core implementation. But actually the reason I wanto to know that is that I don’t really get how the following code in the TemporalMemory::activateCells(…) method is working:

 const auto toColumns = [&](const Segment segment)
  {
    return connections.cellForSegment(segment) / cellsPerColumn_;
  };
  const auto identity = [](const ElemSparse a) {return a;}; 

  for (auto &&columnData : groupBy( //group by columns, and convert activeSegments & matchingSegments to cols. 
           sparse, identity,
           activeSegments_,   toColumns,
           matchingSegments_, toColumns)) 
  {
    Segment column; //we say "column", but it's the first segment of n-segments per cells that belong to the column
    vector<Segment>::const_iterator activeColumnsBegin, activeColumnsEnd, 
	                            columnActiveSegmentsBegin, columnActiveSegmentsEnd, 
                                    columnMatchingSegmentsBegin, columnMatchingSegmentsEnd;

    std::tie(column, 
             activeColumnsBegin, activeColumnsEnd, 
             columnActiveSegmentsBegin, columnActiveSegmentsEnd, 
             columnMatchingSegmentsBegin, columnMatchingSegmentsEnd
	) = columnData;

    const bool isActiveColumn = activeColumnsBegin != activeColumnsEnd;

Especially I’m struggling with the last line. Why is a column active, if the activeColumnsBegin is unequal to the activeColumnsEnd?

Thank you in advance! I really appreciate any help! :slight_smile:

2 Likes

I think it just means if the beginning of the active columns is not the same as the end (I.e. there are more than 0 of them) then it’s considered active.

1 Like

That was also my assumption. But I was not 100% sure if it was correct. :sweat_smile:
But after reading your answer I think it is. Thank you very much! :slight_smile:

Edit: If anyone wants to explain the groupBy method in detail I’ll gladly read it, because I think it can be very confusing to group something by using 3 sequences. Also I think that this method is an important part to fully understand the htm.core implementation.

1 Like