Skip to content

Create new Matrix hirearchy. #329

Merged
cogmission merged 11 commits intonumenta:masterfrom
chelu:low-mem-matrix
Oct 19, 2015
Merged

Create new Matrix hirearchy. #329
cogmission merged 11 commits intonumenta:masterfrom
chelu:low-mem-matrix

Conversation

@chelu
Copy link
Copy Markdown
Contributor

@chelu chelu commented Oct 15, 2015

Create new Matrix hirearchy to allow implementations of FlatMatrix and low memory usage of SparseBinaryMatrix.

Fix #328

chelu added 4 commits October 15, 2015 11:31
Conflicts:
	src/main/java/org/numenta/nupic/Connections.java
	src/test/java/org/numenta/nupic/algorithms/SpatialPoolerTest.java
@cogmission
Copy link
Copy Markdown
Collaborator

@chelu Thanks for adhering to the dev process. Just making sure you see that you need to add tests?

@chelu
Copy link
Copy Markdown
Contributor Author

chelu commented Oct 15, 2015

OK, thanks @cogmission

@cogmission
Copy link
Copy Markdown
Collaborator

@chelu Yep, so this is what I do too. I submit test cases until the build passes :-P

- Update BinarySparseMatrixTest to run test on both implementations.
@cogmission
Copy link
Copy Markdown
Collaborator

@chelu Nice Work!

So can you please explain very briefly the current hierarchy you are proposing? What classes inherit from what and their individual purposes? Also, did you confirm the memory savings? How much memory were you able to save for your implementation?

I just would like to get an understanding of the code and the divisions of responsibility you're proposing...

Thanks,
David

@chelu
Copy link
Copy Markdown
Contributor Author

chelu commented Oct 19, 2015

Hi @cogmission, of course:

  • Matrix: Minimal matrix data access interface
  • FlatMatrix: Extends Matrix for flat index data access. Used to replace SparseObjectMatrix instances that are full indexed like column or pool matrix. Use an array storage instead a map.
  • SparseBinaryMatrixSupport: Base class for SparseBinaryMatrix implementations.
  • LowMemorySparseBinaryMatrix: SparseBinayMatrix without a backing array.
  • BitSetMatrix: a FlatMatrix that store 1/0 in a BitSet instead an integer array.

For a network with a Layer with 512x512 columns with an input for every column, the ConnectedMatrix in Connections will request a backing array of 16 Gb. So I think that having a SparseBinaryMatrix without the backing array is useful.

Note that for actually use it, you need to override SpatialPooler#initMatrices method.

I will try to use BitSetMatrix as replacement of the integer arrays in the future but actually is unused.

Thanks for your support.

Jose.

@cogmission
Copy link
Copy Markdown
Collaborator

Can you change this too? : https://github.com/numenta/htm.java/pull/329/files#diff-542653af02823fbd7e8d10d022c66e84L969

The setter needs to be aligned with the getter

@cogmission
Copy link
Copy Markdown
Collaborator

So in your code are you subclassing the SpatialPooler in order to implement the different matrices? If so, are you running into any problems with the NAPI ? I would rather not have people have to subclass the SpatialPooler, in that light would you recommend the use of one of the other matrices as the default?

@cogmission
Copy link
Copy Markdown
Collaborator

Another small "nit". Can you correct the spacing (to 4 spaces) with no tabs? If you are using Eclipse, you can go to Preferences > Java> Editors and setting indentation to spaces is somewhere there. Then in your edited files, click , to re-indent, or in OSx click , .

@chelu
Copy link
Copy Markdown
Contributor Author

chelu commented Oct 19, 2015

Fixed, No, I haven't problems with NAPI.

@cogmission
Copy link
Copy Markdown
Collaborator

@chelu Awesome! 👍

cogmission added a commit that referenced this pull request Oct 19, 2015
Create new Matrix hirearchy.
@cogmission cogmission merged commit d45ca75 into numenta:master Oct 19, 2015
@cogmission
Copy link
Copy Markdown
Collaborator

@chelu Please keep me informed on your performance observations in gitter, ok?

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants