# Add method on SP to get initialization parameters

**URL:** <https://discourse.numenta.org/t/add-method-on-sp-to-get-initialization-parameters/1124>\
**Category:** NuPIC\
**Tags:** sequence-memory, proposal\
**Created:** [July 27, 2016, 4:51pm UTC](https://discourse.numenta.org/t/add-method-on-sp-to-get-initialization-parameters/1124 "2016-07-27T16:51:39Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![rhyolight](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.numenta.org/rhyolight/32/3922_2.png) [@rhyolight](https://discourse.numenta.org/u/rhyolight)\
**Post date:** [July 27, 2016, 4:51pm UTC](https://discourse.numenta.org/t/add-method-on-sp-to-get-initialization-parameters/1124/1 "2016-07-27T16:51:39Z")

</div>

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`](https://github.com/numenta/nupic/blob/master/src/nupic/research/spatial_pooler.py#L97) 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?

---

<div class="post-metadata">

**Author:** ![mrcslws](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.numenta.org/mrcslws/32/4961_2.png) [@mrcslws](https://discourse.numenta.org/u/mrcslws)\
**Post date:** [July 27, 2016, 5:30pm UTC](https://discourse.numenta.org/t/add-method-on-sp-to-get-initialization-parameters/1124/2 "2016-07-27T17:30:11Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![rhyolight](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.numenta.org/rhyolight/32/3922_2.png) [@rhyolight](https://discourse.numenta.org/u/rhyolight)\
**Post date:** [July 27, 2016, 5:33pm UTC](https://discourse.numenta.org/t/add-method-on-sp-to-get-initialization-parameters/1124/3 "2016-07-27T17:33:44Z")

</div>

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](https://github.com/numenta/nupic/blob/master/src/nupic/research/spatial_pooler.py#L1805-L1826)

I think a helper function would be fine.

---

<div class="post-metadata">

**Author:** ![rhyolight](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.numenta.org/rhyolight/32/3922_2.png) [@rhyolight](https://discourse.numenta.org/u/rhyolight)\
**Post date:** [July 30, 2016, 4:52pm UTC](https://discourse.numenta.org/t/add-method-on-sp-to-get-initialization-parameters/1124/4 "2016-07-30T16:52:09Z")

</div>

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