|
36 | 36 | #include <iterator> |
37 | 37 | #include <string> |
38 | 38 | #include <vector> |
| 39 | +#include <set> |
39 | 40 |
|
40 | 41 |
|
41 | 42 | #include <htm/algorithms/TemporalMemory.hpp> |
@@ -377,7 +378,7 @@ void TemporalMemory::activateCells(const SDR &activeColumns, const bool learn) { |
377 | 378 |
|
378 | 379 | // for column in activeColumns (the 'sparse' above): |
379 | 380 | // get its active segments ( >= connectedThr) |
380 | | - // get its matching segs ( >= mmm |
| 381 | + // get its matching segs ( >= TODO |
381 | 382 | std::tie(column, |
382 | 383 | activeColumnsBegin, activeColumnsEnd, |
383 | 384 | columnActiveSegmentsBegin, columnActiveSegmentsEnd, |
@@ -603,16 +604,15 @@ SDR TemporalMemory::getPredictiveCells() const { |
603 | 604 | correctDims.push_back(static_cast<CellIdx>(getCellsPerColumn())); |
604 | 605 | SDR predictive(correctDims); |
605 | 606 |
|
606 | | - auto& predictiveCells = predictive.getSparse(); |
| 607 | + std::set<CellIdx> uniqueCells; |
| 608 | + //uniqueCells.reserve(activeSegments_.size()); |
607 | 609 |
|
608 | | - for (auto segment = activeSegments_.cbegin(); segment != activeSegments_.cend(); |
609 | | - segment++) { |
610 | | - const CellIdx cell = connections.cellForSegment(*segment); |
611 | | - if (segment == activeSegments_.begin() || cell != predictiveCells.back()) { |
612 | | - predictiveCells.push_back(cell); |
613 | | - } |
| 610 | + for (const auto segment : activeSegments_) { |
| 611 | + const CellIdx cell = connections.cellForSegment(segment); |
| 612 | + uniqueCells.insert(cell); //set keeps the cells unique |
614 | 613 | } |
615 | 614 |
|
| 615 | + vector<CellIdx> predictiveCells(uniqueCells.begin(), uniqueCells.end()); |
616 | 616 | predictive.setSparse(predictiveCells); |
617 | 617 | return predictive; |
618 | 618 | } |
|
0 commit comments