Update the Python ETM to use the new "walk the columns" strategy
mrcslws opened this issue · comments
Here's the current status of our temporal memory implementations:
C++ | Python | |
---|---|---|
TemporalMemory | New | New |
ExtendedTemporalMemory | New | Old (phases) |
The change here is to update the Python ExtendedTemporalMemory to use the new approach. At the end of this, the ETM algorithm tests should pass, and hopefully the Python and C++ ETM will behave identically.
The new approach walks each column once, doing all cell activation and learning for that column, then moving on to the next. It uses sorted lists of columns, cells, and segments, and it walks them all simultaneously, which avoids doing set
lookups. It avoids building a pool of "learning segments", making it much easier to understand exactly where synapses are grown / reinforced / punished. This new approach is also easy to parallelize, should we ever want to.
Benefits of this change:
- Faster code
- Cleaner code (according to Marcus)
- Fixes #582
- Uses the updated Python
Connections
class which supports synapse/segment cleanup. - Unifies our two ETM implementations so that we can test them by verifying that they get identical results.
- Removes a consumer of
temporal_memory_phases
andconnections_phases
, which we want to remove.
Here's how someone might do this:
- Copy-paste
temporal_memory.py
intoextended_temporal_memory.py
, and rename it. - Change the code the same way that we changed the C++ TM to the C++ ETM.
- Copy-paste
temporal_memory_test.py
intoetm_unit_test.py
and change it to use the ETM instead of TM.
Notes:
- I changed the C++
Connections
to have a "SegmentExcitationTally" that could be used by the C++ ETM instead ofcomputeActivity
. I don't think this change will be necessary in the Python -- we can just concatenate lists together viaitertools.chain
(example) and pass it intocomputeActivity
. - Definitely use our Python
groupby2
function which is already used intemporal_memory.py
. The current implementation is ready for the ETM.
Before starting on this we should fix the tests broken by the recent maxNewSynapseCount
change here. That is, running the tests in tests/extended_temporal_memory/ results in multiple failures. @mrcslws has confirmed this. @subutai do you have any suggestions or should I go ahead and fix these tests?
We split out the two synapse change issues for temporal_memory:
numenta/nupic-legacy#3268
numenta/nupic-legacy#3292
For temporal_memory_phases the change is still in there - I'm working through it slowly as I might need that change for ColumnPooler.
@BoltzmannBrain Reversed my change in this PR: numenta/nupic.research#606