Add method on SP to get initialization parameters

I would like to be able to fetch the params used to initialize the spatial pooler without hand-picking values from protected variables in the SP instance.

Specifically, I want to add a getParameters() method to the SpatialPooler class that returns all the values sent into the constructor in a dict keyed by param name.

I assume something similar needs to be done to the C++ SP, right?

Any objections or opinions?

This won’t translate super-cleanly to C++, which doesn’t have a dict-of-arbitrary-types type. This method would probably have to return a struct. Options that come to mind:

  1. Return a struct, and make the Python bindings translate it into a dict.
  2. Only expose this method to Python callers. Add it to the SWIG SpatialPooler but don’t change the core C++ SpatialPooler.
  3. Don’t add a new method. Put a Python helper function somewhere. It will call the SpatialPooler’s getters and build up this dictionary. This function could live in spatial_pooler.py. It will work with the Python and C++ SP.

I don’t have a strong opinion, but I like option 3.

Aha, I did not realize there were getters for every param:

https://github.com/numenta/nupic/blob/master/src/nupic/research/spatial_pooler.py#L1805-L1826

I think a helper function would be fine.

This topic was automatically closed after 3 days. New replies are no longer allowed.