Skip to content
This repository has been archived by the owner on Sep 1, 2023. It is now read-only.

Full sync of C++ temporal memory to Python temporal memory #3254

Merged
merged 45 commits into from Aug 15, 2016

Conversation

andrewmalta13
Copy link
Contributor

@andrewmalta13 andrewmalta13 commented Aug 8, 2016

fixes #3239
fixes #3253
fixes #3240
fixes #3199
fixes #3230
fixes #1511
fixes #2999
fixes #2980

  • Rewrite of connections.py and connections_tests.py
  • Implements group_by.py and group_by_tests.py to be up to date with this soon to be merged pr to the c++ temporal memory.
  • Reconfigures temporal_memory.py to use the new group_by method as opposed to the excitedColumnGenerator.
  • Fixes serialization of the connections datastructure.
  • bug fixes in temporal_memory.py
  • compatibility test now can be run and it should pass when marcus' pr is merged into nupic.core.

Edit: This change is now ~7-10% faster than the current implementation (about 30% faster than the original phases TM). Compatibility tests pass and fixes a bunch of tm issues in nupic.

Please Review:
@mrcslws @scottpurdy

CC:
@cogmission

@numenta-ci
Copy link
Contributor

By analyzing the blame information on this pull request, we identified @david-ragazzi, @chetan51 and @scottpurdy to be potential reviewers



class SynapseData(object):
class Segment(object):
''' Class containing mininal information to identify a unique segment '''
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo: minimal

@cogmission
Copy link
Contributor

@andrewmalta13 @mrcslws Just a small question and hope that the occurrence and usage of the new GroupByGenerator will be accompanied by documentation of what it accomplishes within the context of the TemporalMemory? I'm sure it will, but I'm just making sure... ;-)

@mrcslws
Copy link
Contributor

mrcslws commented Aug 14, 2016

@cogmission the GroupByGenerator is an implementation detail. The thing to pay attention to is groupByN, which is essentially just itertools.groupby extended to work with multiple sequences. As long as the groupByN docstring is good, I think we're fine.

__slots__ = ['iterable', 'beginning', 'length', 'end', 'index']

def __init__(self, iterable, beginning, length):
self.iterable = iterable
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is "iterable" an appropriate name? Iterables don't necessarily support index lookup. Just calling it lis would be good.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lis? Does not seem like a good name to me. Is it a Python sequence?

self.activeSegments, segToCol,
self.matchingSegments, segToCol):
(column,
activeColumns,
activeSegmentsOnCol,
matchingSegmentsOnCol) = columnData
if len(activeColumns):
if len(activeSegmentsOnCol) != 0:
if not activeColumns is None:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For these it's better to do is not None.

I just checked and it's in PEP-8: "Use is not operator rather than not ... is" https://www.python.org/dev/peps/pep-0008/



def groupby2(*args):
""" An extension to groupby in itertools. Allows to
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: reformat the paragraph now that this line is narrower

@mrcslws
Copy link
Contributor

mrcslws commented Aug 15, 2016

I played with the nupic.research code that still uses Connections (faulty_temporal_memory, phases_temporal_memory, and by extension the ExtendedTemporalMemory and its unit/integration tests).

We'll have to make lots of updates to that code if we want it to keep working with this change.

I think we should go ahead and copy-paste the old code into connections_phases.py in nupic.research rather than trying to keep all these old implementations working with the latest connections.

@mrcslws
Copy link
Contributor

mrcslws commented Aug 15, 2016

Done reviewing, very nice work! 👍

@scottpurdy
Copy link
Contributor

👍

generator objects, allowing for groupByN to not have to capture the
group in a list.

@param lis (list) the list to perform the groupby on
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this have to be a list? Can it be any sequence type?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you're commenting on old code. The latest is here: https://github.com/numenta/nupic/blob/master/src/nupic/support/group_by.py

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

K thx, I was going through old email and saw unresponded-to-comments making me think it was current code.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.