# Preferred way to pass recognized sequences from Temporal Memory to a "higher HTM layer"?

**URL:** https://discourse.numenta.org/t/preferred-way-to-pass-recognized-sequences-from-temporal-memory-to-a-higher-htm-layer/10137
**Category:** NuPIC
**Tags:** sequence-memory, question
**Created:** [September 28, 2022, 7:11pm UTC](https://discourse.numenta.org/t/preferred-way-to-pass-recognized-sequences-from-temporal-memory-to-a-higher-htm-layer/10137 "2022-09-28T19:11:39Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![Markus](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.numenta.org/markus/32/6033_2.png) [@Markus](https://discourse.numenta.org/u/Markus)
#### Post date: [September 28, 2022, 7:11pm UTC](https://discourse.numenta.org/t/preferred-way-to-pass-recognized-sequences-from-temporal-memory-to-a-higher-htm-layer/10137/1 "2022-09-28T19:11:39Z")

</div>

Say I have trained a Temporal Memory instance with letters (encoded as SDRs) to distinguish sequences like “GEC” or “DEF” and predict the letter C after GE or the letter F after input of DE, something like it was seen in this one video from the HTM School series (High Order Memory vs. Single Order Memory). How can I use the recognized sequences as input in another Spatial Pooler or Temporal Memory?

My first guess would be some sort of SDR hashing: copy those SDRs in a row that make up the sequence and form a hash value, which you in turn encode as an SDR.

Another idea would be to let the Spatial Pooler solve this task by taking the sequence as input for the SP - which unfortunately has the problem that the sequences can be of different lengths.

---

<div class="post-metadata">

### Author: ![dmac](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.numenta.org/dmac/32/5842_2.png) [@dmac](https://discourse.numenta.org/u/dmac)
#### Post date: [September 28, 2022, 11:48pm UTC](https://discourse.numenta.org/t/preferred-way-to-pass-recognized-sequences-from-temporal-memory-to-a-higher-htm-layer/10137/2 "2022-09-28T23:48:18Z")

</div>

Hi,

IMO hashing is a bad idea. It is certainly not what the brain does. A problem with hashing an SDR is that the hash depends on the exact value of the SDR, so if even a single cell’s activity is different then the hash will be totally different. Hashes don’t account for the semantic similarities between their inputs.

* * *

This article describes a good solution to your problem.  
[(PDF) Learning Invariance From Transformation Sequences. Foldiak, 1991](https://www.researchgate.net/publication/215991433_Learning_Invariance_From_Transformation_Sequences)

I’ve personally tested this solution and you can see my results at the end of the video I recorded about it. In the video: I created a temporal memory (TM) and fed words into it, one letter at a time. Then I used this method to make an SDR that represents the current word, given only the output of the TM.

> [@Video Lecture of Kropff & Treves, 2008](https://discourse.numenta.org/t/video-lecture-of-kropff-treves-2008/6907):
>
> Update: I recorded a video lecture on this topic: [[Kropff &amp; Treves, 2008 for Numenta and the HTM Forum] ](https://www.youtube.com/watch?v=7IM8czdiOuo) The slides are at [https://github.com/ctrl-z-9000-times/KropffTreves2008\_reproduction/blob/master/grid\_cells\_presentation.pdf](https://github.com/ctrl-z-9000-times/KropffTreves2008_reproduction/blob/master/grid_cells_presentation.pdf) References Kropff & Treves, 2008 HTM Spatial Pooler A Theory of How Columns in the Neocortex Enable Learning the Structure of the World

---

<div class="post-metadata">

### Author: ![Markus](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.numenta.org/markus/32/6033_2.png) [@Markus](https://discourse.numenta.org/u/Markus)
#### Post date: [November 5, 2022, 10:51pm UTC](https://discourse.numenta.org/t/preferred-way-to-pass-recognized-sequences-from-temporal-memory-to-a-higher-htm-layer/10137/3 "2022-11-05T22:51:34Z")

</div>

Hi,  
many many thanks! This experiment with Temporal Memory ( TM ), fed words and low-pass filter is very interesting. Do you have a script at hand showing how the experiment is set up?

---

<div class="post-metadata">

### Author: ![dmac](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.numenta.org/dmac/32/5842_2.png) [@dmac](https://discourse.numenta.org/u/dmac)
#### Post date: [November 6, 2022, 1:31am UTC](https://discourse.numenta.org/t/preferred-way-to-pass-recognized-sequences-from-temporal-memory-to-a-higher-htm-layer/10137/4 "2022-11-06T01:31:24Z")

</div>

Hi,  
The experiment shown in that lecture uses my own implementation of an HTM, and I’ve got to warn you that it’s experimental (not production ready) and that I no longer maintain that implementation at all.

I wrote a report about that experiment, which explains in detail how I did it: [sdr\_algorithms/ascii\_stability.pdf at master · ctrl-z-9000-times/sdr\_algorithms · GitHub](https://github.com/ctrl-z-9000-times/sdr_algorithms/blob/master/ascii_stability.pdf)

And here is the experimental setup source-code: [sdr\_algorithms/ascii\_stability.py at master · ctrl-z-9000-times/sdr\_algorithms · GitHub](https://github.com/ctrl-z-9000-times/sdr_algorithms/blob/master/func_tests/ascii_stability.py)

I hope this helps, if you have any other questions I’d be happy to hear them!

---

<div class="post-metadata">

### Author: ![Markus](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.numenta.org/markus/32/6033_2.png) [@Markus](https://discourse.numenta.org/u/Markus)
#### Post date: [November 7, 2022, 10:14pm UTC](https://discourse.numenta.org/t/preferred-way-to-pass-recognized-sequences-from-temporal-memory-to-a-higher-htm-layer/10137/5 "2022-11-07T22:14:41Z")

</div>

hey thanks for sharing!

I tried running ascii\_stability.py and got this:  
from synapses import SynapseManager  
ModuleNotFoundError: No module named ‘synapses’

In my cloned repo/directory I got this synapses.pyx file. Haven’t used cython before but I guess that I need this to make it work, right?

---

<div class="post-metadata">

### Author: ![dmac](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.numenta.org/dmac/32/5842_2.png) [@dmac](https://discourse.numenta.org/u/dmac)
#### Post date: [November 8, 2022, 1:47pm UTC](https://discourse.numenta.org/t/preferred-way-to-pass-recognized-sequences-from-temporal-memory-to-a-higher-htm-layer/10137/6 "2022-11-08T13:47:48Z")

</div>

Yes, first you need to install and run cython.  
The following command should work on linux:

```auto
./setup.py build_ext --build-lib `pwd`/../

```

If you’re on windows then you’ll need to replace the “`pwd`/…/” part with the directory that contains the sdr\_algorithms folder.
