-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixes #1903 - Re-use Connections class in SP #2066
Conversation
d23c608
to
5c46aab
Compare
wow 🆒 A really exciting change! I think I'll need a brain for the review, so I'll leave that for tmr, but it looks really 👍 👍 |
@breznak haha.. Really this won't an easy job, I even had took advantage that I was with fresh brain and without distractions to finally work on this.. If this improvement has similar or better performance (who knows), then we should say goodbye to the sparse matrix.. and so finally SP will be more intuitive to understand.. :-D Talking about performance, in the current state of this PR, SP has to transverse synapses to get the input indices which they are connected at every time that such indices are need. I'm thinking of use dicts for perform this operation once and so gain performance.. I'm open to suggestions.. |
I think this would also fix this old pal, #1385 |
I've just cleaned up the python benchmark PR, so you can use #1928 to measure the new SP performance. |
5c46aab
to
b8b228e
Compare
synapses = self.connections.synapsesForSegment(i) | ||
inputIndices = self._getInputIndexesFromSynapses(synapses) | ||
perm = self._getPermanencesFromColumn(i) | ||
perm += permChanges[inputIndices] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
some trouble in adaptSynapses() and the failing test https://travis-ci.org/numenta/nupic/jobs/59624260#L3493
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
some trouble in adaptSynapses() and the failing test https://travis-ci.org/numenta/nupic/jobs/59624260#L3493
Yep, I did fix it.
331693f
to
11113e1
Compare
@david-ragazzi You can now consolidate this PR with #2080. |
aab0b2b
to
031c122
Compare
Done. |
@david-ragazzi @rhyolight Was this merged along with #2080 ? |
Nope. #2080 was only to move Connections from TemporalMemory (which was a partial change of this PR, but I removed)... This PR is about re-use connections in SP.. @cogmission Keep on eye on this, because it's important to This change also is important to |
031c122
to
7bd824c
Compare
@@ -1308,7 +1358,9 @@ def _calculateOverlap(self, inputVector): | |||
the spatial pooler. | |||
""" | |||
overlaps = numpy.zeros(self._numColumns).astype(realDType) | |||
self._connectedSynapses.rightVecSumAtNZ_fast(inputVector, overlaps) | |||
for i in xrange(self._numColumns): | |||
inputIndices = self._getInputIndicesFromSynapsesForColumn(i) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TODO: I need pass onlyConnected=True
here.
Does anyone know the status of this? |
afaik, blocked by "serialization stuff"
|
Ah thanks! |
Serialization for Connections is completed: #2100 |
Fixes: #1903
Depends: #1449
Ladies and gentlemen, now SP also has connections! Connections class is a prime by @chetan51 which allow us to separate net specification from net state. This seems simple but has a lot of implications to make nupic easier to understanding and mantaining. This class is so abstract when comes to segments and synapses that I managed adapt it to SP without need create any additional method but only re-using the existing ones.
Some important changes:
_potentialPools
was removed: Now SP create synapses to all input bits that are in potential area of a column. So when methods like_adaptSynapses
,_bumpUpWeakColumns
,_updatePermanencesForColumn
, need update synapses's permanencies, they don't need handle amapPotential
but simply handle directly such synapses of the column or get the indices of the input bits which they are connected._permanences
was removed: Now SP uses a dict to get permanencies from an individual column and put them into a temporary numpy array to perform changes (perm
). After permanencies operations is done, SP updates the synapses of a column with the new permanencies values (using _updatePermanencesForColumn method).I compared the performance without or with these changes and I feel litle difference. But it is desirable we have more eyes on this.
This PR still is not ready because I still have to implement serialization for Connections and more tests are need to we find areas for improvement.
TODO: