# Reverse SDR Classifier?

**URL:** https://discourse.numenta.org/t/reverse-sdr-classifier/2716
**Category:** NuPIC
**Created:** [August 22, 2017, 6:33pm UTC](https://discourse.numenta.org/t/reverse-sdr-classifier/2716 "2017-08-22T18:33:57Z")
**Posts on this page:** 13
**Page:** 1

<div class="post-metadata">

### Author: ![Sergey](https://avatars.discourse-cdn.com/v4/letter/s/9fc348/32.png) [@Sergey](https://discourse.numenta.org/u/Sergey)
#### Post date: [August 22, 2017, 6:33pm UTC](https://discourse.numenta.org/t/reverse-sdr-classifier/2716/1 "2017-08-22T18:33:57Z")

</div>

Hi !  
Do you have classifier, the output of which is SDR ?

Thanx a lot!

---

<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: [August 22, 2017, 6:36pm UTC](https://discourse.numenta.org/t/reverse-sdr-classifier/2716/2 "2017-08-22T18:36:19Z")

</div>

If you want an SDR from the TM, you can get the winner cells or predictive cells. But these SDRs are usually “decoded” by the encoder that created the input SDR.

What is your use-case for this?

---

<div class="post-metadata">

### Author: ![Sergey](https://avatars.discourse-cdn.com/v4/letter/s/9fc348/32.png) [@Sergey](https://discourse.numenta.org/u/Sergey)
#### Post date: [August 22, 2017, 7:17pm UTC](https://discourse.numenta.org/t/reverse-sdr-classifier/2716/3 "2017-08-22T19:17:17Z")

</div>

We need an SDR, which will contain information about features predicted in TM and from encoder at the same time. We are going to use it as an input of SP of the next level in the hierarchy.

Is there at least a classifier, which can make classification not based on the encoder, but creating a set of new (not related to the encoder directly) features?

---

<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: [August 22, 2017, 7:30pm UTC](https://discourse.numenta.org/t/reverse-sdr-classifier/2716/4 "2017-08-22T19:30:58Z")

</div>

I don’t think you want a classifier here. If you want to get meaningful semantic SDRs from the SP/TM algorithms, you’ll want to get the winner cells from the TM. That is your SDR to pass up to the next layer.

(@scott @mrcslws correct me if I’m wrong)

---

<div class="post-metadata">

### Author: ![scott](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.numenta.org/scott/32/170_2.png) [@scott](https://discourse.numenta.org/u/scott)
#### Post date: [August 22, 2017, 7:55pm UTC](https://discourse.numenta.org/t/reverse-sdr-classifier/2716/5 "2017-08-22T19:55:18Z")

</div>

The active cells are what would be passed up the hierarchy. But you probably won’t get any improved results simply by stacking SP/TM in a hierarchy.

If you are using the new TemporalMemory class, you can get the active cells with `tm.getActiveCells()` and if you are using the network API then you can pull out the TM class from the region with `tmRegion.getSelf().getAlgorithmInstance()`. These methods will be different if you’re using the other TM implementation though.

---

<div class="post-metadata">

### Author: ![spin](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.numenta.org/spin/32/1539_2.png) [@spin](https://discourse.numenta.org/u/spin)
#### Post date: [August 22, 2017, 8:42pm UTC](https://discourse.numenta.org/t/reverse-sdr-classifier/2716/6 "2017-08-22T20:42:58Z")

</div>

Thank you for the details.  
Nevertheless, we don’t need improved results, we want to have a classification of patterns, where every prediction isn’t an element from the encoder.  
Let’s say we have in our encoder some fruits properties, like color, size, and shape, and we want to see as the result apple, banana, and lemon.

---

<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: [August 22, 2017, 8:56pm UTC](https://discourse.numenta.org/t/reverse-sdr-classifier/2716/7 "2017-08-22T20:56:17Z")

</div>

So you have an encoder that is encoding semantic meaning? Meaning you have subclassed [`BaseEncoder`](http://nupic.docs.numenta.org/1.0.2/api/algorithms/encoders.html#base-encoder)? To do the decoding, you use the [`SDRClassifier`](http://nupic.docs.numenta.org/1.0.2/api/algorithms/classifiers.html#module-nupic.algorithms.sdr_classifier). But you _MUST_ implement the decoding logic in your encoder as well. I think you do this by implementing [`getBucketIndices`](http://nupic.docs.numenta.org/1.0.2/api/algorithms/encoders.html#nupic.encoders.base.Encoder.getBucketIndices), which will convert an SDR into a bucket index. [`ScalarEncoder`](https://github.com/numenta/nupic/blob/1.0.2/src/nupic/encoders/scalar.py#L391) has an example of this.

---

<div class="post-metadata">

### Author: ![spin](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.numenta.org/spin/32/1539_2.png) [@spin](https://discourse.numenta.org/u/spin)
#### Post date: [August 23, 2017, 2:43am UTC](https://discourse.numenta.org/t/reverse-sdr-classifier/2716/8 "2017-08-23T02:43:57Z")

</div>

We use a scalar encoder, and it does encode semantic meaning, but we need another set of meaning as the result. So, we can’t use SDRClassifier, which is hardwired (correct me if I’m wrong) to use the meanings from the encoder.

---

<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: [August 23, 2017, 3:18am UTC](https://discourse.numenta.org/t/reverse-sdr-classifier/2716/9 "2017-08-23T03:18:22Z")

</div>

I think what you are trying to do is some type of object recognition via temporal pooling. Are you interested in extracting information about the what temporal sequences are currently being recognized? NuPIC doesn’t do temporal pooling, but our current research on SMI does. However this is still experimental research code. We are publishing papers about it, but there is no concrete production implementation.

---

<div class="post-metadata">

### Author: ![dorinclisu](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.numenta.org/dorinclisu/32/506_2.png) [@dorinclisu](https://discourse.numenta.org/u/dorinclisu)
#### Post date: [August 23, 2017, 8:43am UTC](https://discourse.numenta.org/t/reverse-sdr-classifier/2716/10 "2017-08-23T08:43:18Z")

</div>

> [@rhyolight](#):
>
> To do the decoding, you use the SDRClassifier. But you MUST implement the decoding logic in your encoder as well. I think you do this by implementing getBucketIndices, which will convert an SDR into a bucket index. ScalarEncoder has an example of this.

`getBucketIndices` has nothing to do with SDR’s, it does not encode or decode, it just maps the input space to buckets.

It’s possible to implement decoding logic in the encoder, but not necessary. So far none of the nupic encoders have any decoding function.

The classifier does the SDR decoding into input buckets (which can be mapped back to the input space using the inverse of `getBucketIndices`) by means of probabilistic association, with no regards to the encoder.

---

<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: [August 23, 2017, 1:27pm UTC](https://discourse.numenta.org/t/reverse-sdr-classifier/2716/11 "2017-08-23T13:27:39Z")

</div>

Thanks for the correction. I’ve only dealt with decoding / classification I little bit.

---

<div class="post-metadata">

### Author: ![spin](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.numenta.org/spin/32/1539_2.png) [@spin](https://discourse.numenta.org/u/spin)
#### Post date: [August 23, 2017, 4:01pm UTC](https://discourse.numenta.org/t/reverse-sdr-classifier/2716/12 "2017-08-23T16:01:40Z")

</div>

Thank you for the clarification.  
To sum up, there isn’t, for now, any way to do classification with HTM, which is not based on input information. To solve such a problem, you have to implement your own logic.

---

<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: [August 23, 2017, 4:06pm UTC](https://discourse.numenta.org/t/reverse-sdr-classifier/2716/13 "2017-08-23T16:06:44Z")

</div>

I do think you are correct about that.
