numenta / nupic-legacy

Numenta Platform for Intelligent Computing is an implementation of Hierarchical Temporal Memory (HTM), a theory of intelligence based strictly on the neuroscience of the neocortex.
http://numenta.org/
GNU Affero General Public License v3.0
6.33k stars 1.56k forks source link

Optimization to spatial_pooler.py initialization. Fixes #1385 #3817

Closed ctrl-z-9000-times closed 6 years ago

ctrl-z-9000-times commented 6 years ago

I rewrote some of the SpatialPooler's initialization code to run faster by using Numpy instead of python "for" loops.

This is related to issue #1385 which complains that the SP.init is slow. Issue #1385 is about using dense arrays to represent the potential synapses for each column. The dense boolean arrays are iterated over by the function _initPermanence. Issue #1385 calls for replacing these dense boolean arrays with a sparse array of indices. Instead of directly fixing issue #1385 I instead made the surrounding code more capable of working with dense arrays. This is accomplished primarily through the use of the function numpy.nonzero which converts the dense boolean arrays into sparse index arrays.

rhyolight commented 6 years ago

@ctrl-z-9000-times This repo is currently in maintenance mode and we are now accepting new features or enhancements. (All our engineers are currently doing research.) We use the C++ Spatial Pooler when we need speed. The python SP is really there for easy prototyping and readability.

You might find that the community fork will accept your contributions, however.