Can a region output a sparse array -reposted?

( Reposted to nupic from HTM hackers - no reply there)

I have written my own region (as explained in another post 1) and I wanted it to output a sparse array of column indices. However this does not seem to be possible?

The problem is that wraps all outputs as an object of the class DictReadOnlyWrapper at line 186:

186 return self.compute(inputs, DictReadOnlyWrapper(outputs))     

As a consequence of this you do not seem to be able to change the shape of the output array after it is first assigned.

Is my reading of the situation correct or is there a way to get a sparse output from a region? (Assuming the number of entries in such an array varies.)

For reference, just in case my code is in error, I tried to assign a sparse array to an output in my region as follows:


When you say “sparse output”, you mean an array of indices representing the on locations, right? If so, it’s easy to translate back and forth. Is there an optimization issue with doing that manually?

Yes by sparse output I meant an array of indices. I realize it is easy to convert back and forth (but inefficient to do so). What I am asking for is confirmation that I have understood correctly that when using the Network API there is a constraint on the design of the regions that their inputs and outputs must be a dense array? (I cannot see this stated in the documentation but it is my interpretation of the source code.)

I don’t know for sure. But perhaps @David_Keeney or @breznak could tell you how it works in nupic.cpp? They might actually know the answer for NuPIC as well. I will ask @lscheinkman about this Monday. He might know.

Hi, I believe the API does not dictate this, and in nupic.cpp (now htm.core) regions output sparse arrays (respectively SDR object which can toggle between desired interpretation very fast).
Try to use that code.

Regions are limited to fixed dimensions (if that’s what I understood from your post)

1 Like