# Can HTM predict previous inputs?

**URL:** <https://discourse.numenta.org/t/can-htm-predict-previous-inputs/5597>\
**Category:** NuPIC\
**Created:** [March 9, 2019, 11:24am UTC](https://discourse.numenta.org/t/can-htm-predict-previous-inputs/5597 "2019-03-09T11:24:21Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![simon.1](https://avatars.discourse-cdn.com/v4/letter/s/9d8465/32.png) [@simon.1](https://discourse.numenta.org/u/simon.1)\
**Post date:** [March 9, 2019, 11:24am UTC](https://discourse.numenta.org/t/can-htm-predict-previous-inputs/5597/1 "2019-03-09T11:24:21Z")

</div>

Other than entering the data in reverse order, can HTM predict previous inputs? A case where this would be useful would be in question answering. Taking the “what does the fox eat” example further, we may wish to ask questions like “What eats mice?”, where the data contains factoids like “foxes eat mice”. Input “eats mice” and predict “foxes”.

---

<div class="post-metadata">

**Author:** ![marty1885](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.numenta.org/marty1885/32/1891_2.png) [@marty1885](https://discourse.numenta.org/u/marty1885)\
**Post date:** [March 9, 2019, 2:22pm UTC](https://discourse.numenta.org/t/can-htm-predict-previous-inputs/5597/2 "2019-03-09T14:22:54Z")

</div>

Good point! Technically yes by walking the synapses backward - not saying that anyone has done it. And it seems to be biologically impossible.

I don’t know how this coule be solved in HTM. Maybe some one else here can?

---

<div class="post-metadata">

**Author:** ![LuizCoutinho](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.numenta.org/luizcoutinho/32/3703_2.png) [@LuizCoutinho](https://discourse.numenta.org/u/LuizCoutinho)\
**Post date:** [March 9, 2019, 3:54pm UTC](https://discourse.numenta.org/t/can-htm-predict-previous-inputs/5597/3 "2019-03-09T15:54:30Z")

</div>

I think the hierarchy is needed to solve this being biologically plausible. Reversing the sequence order would not be a solution, for example: you learned the ABCD sequence and want to figure out which is the first element of the ?BCD, so you would need to learn DCBA to predict A after the DCB, but I don’t think that’s what you want.

---

<div class="post-metadata">

**Author:** ![simon.1](https://avatars.discourse-cdn.com/v4/letter/s/9d8465/32.png) [@simon.1](https://discourse.numenta.org/u/simon.1)\
**Post date:** [March 9, 2019, 7:33pm UTC](https://discourse.numenta.org/t/can-htm-predict-previous-inputs/5597/4 "2019-03-09T19:33:14Z")

</div>

Does the following method of predicting previous inputs work? … The pattern of active cells in the TM is are all in the columns of the last input, but the activation within each column is determined by the full sequence of prior inputs. Thus we could train a classifier acting on the TM active cells to recognise labelled full sequences. But what I am not clear about, is if we then apply an input sequence which is missing the first element, will the TM and its classified provide a probability of each of the possible full sequences that have previously been learned, and hence if suitably labelled by the classifier the missing first input (or more previous inputs) could be deduced?

---

<div class="post-metadata">

**Author:** ![Casey](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.numenta.org/casey/32/2874_2.png) [@Casey](https://discourse.numenta.org/u/Casey)\
**Post date:** [March 10, 2019, 2:56am UTC](https://discourse.numenta.org/t/can-htm-predict-previous-inputs/5597/5 "2019-03-10T02:56:29Z")

</div>

> [@marty1885](#):
>
> Good point! Technically yes by walking the synapses backward - not saying that anyone has done it. And it seems to be biologically impossible.

During sleep, sequences of firing replay in the hippocampus and I think I remember also cortex. They can play in reverse. It probably has something to do with locations and paths in environments.

---

<div class="post-metadata">

**Author:** ![simon.1](https://avatars.discourse-cdn.com/v4/letter/s/9d8465/32.png) [@simon.1](https://discourse.numenta.org/u/simon.1)\
**Post date:** [March 10, 2019, 11:14am UTC](https://discourse.numenta.org/t/can-htm-predict-previous-inputs/5597/6 "2019-03-10T11:14:48Z")

</div>

Yes I did not want to learn the sequence DCBA in to predict A from DCB. Your point about using a hierarchy is an interesting one – can you explain further? Perhaps one way to do it is to copy the SDR of the first term to the “upper level”, providing persistence of the “subject” as the subsequent terms in the sequence are learned, with apic feedback of the subject as each successive term is learned? But I am not sure how to actually do this with the nupic api? This seems to need “research code”, for example the [Apical Temporal Memory](https://github.com/numenta/htmresearch/blob/master/htmresearch/algorithms/apical_dependent_temporal_memory.py). I have also found discussion of "[Extended Temporal Memory](https://github.com/numenta/htmresearch/wiki/Extended-Temporal-Memory) " but the links to the code are broken so I am presuming that Apical Temporal Memory has superseded it? Has anyone got any experience of using Apical Temporal Memory (and are there other research codes that are relevant to this conversation?).

Also, I am not really clear how apical feedback differs from simply adding a new basal input which is linked together to hold the “upper level” data (the “subject” in this case, but also other contextual information). This would seem not to require any new nupic code, just a bit of plumbing.

---

<div class="post-metadata">

**Author:** ![LuizCoutinho](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.numenta.org/luizcoutinho/32/3703_2.png) [@LuizCoutinho](https://discourse.numenta.org/u/LuizCoutinho)\
**Post date:** [March 11, 2019, 12:38am UTC](https://discourse.numenta.org/t/can-htm-predict-previous-inputs/5597/8 "2019-03-11T00:38:34Z")

</div>

My opinion that this issue needs the hierarchy is because, if I have correctly understood your question, the sequence memory does not seem to be sufficient to solve this by itself, I think it is a process that involves semantic memory and, as far as I know, the semantic knowledge is stored in distinct associative cortices and its evocation depends on the pre-frontal cortex. I started studying the HTM theory a short time ago and I’m not familiar with the nupic, so I can not help you much more, it would be better someone with more experience to comment on it.  
this conversation may be relevant:

> [@Alternative sequence memory](https://discourse.numenta.org/t/alternative-sequence-memory/3898/11):
>
> The brain is unlike a computer in that a computer is very precise (ie if you change one bit in a byte in computer memory it changes the whole meaning of the representation, whereas in the brain it only slightly changes the meaning). The brain tends to be unprecise because it facilitates flexibility. SDRs are a great example of flexibility. However it seems sequence memory in computers tend to be quite rigid. The shifting example above - it encodes ABCD in that exact sequence. ABCD can be content…

---

<div class="post-metadata">

**Author:** ![Paul\_Lamb](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.numenta.org/paul_lamb/32/2725_2.png) [@Paul\_Lamb](https://discourse.numenta.org/u/Paul_Lamb)\
**Post date:** [March 11, 2019, 12:24pm UTC](https://discourse.numenta.org/t/can-htm-predict-previous-inputs/5597/9 "2019-03-11T12:24:29Z")

</div>

While not specifically a NuPIC answer, I think this could be done relatively easily without a hierarchy by using a similar classifier strategy as has been used for predicting multiple timesteps into the future (see [this video](https://youtu.be/QZBtaP_gcn0?t=1239) for an example of how that is done). The difference would be to have it tracking the frequency of inputs from some number of timesteps in the past.

---

<div class="post-metadata">

**Author:** ![simon.1](https://avatars.discourse-cdn.com/v4/letter/s/9d8465/32.png) [@simon.1](https://discourse.numenta.org/u/simon.1)\
**Post date:** [March 12, 2019, 12:04pm UTC](https://discourse.numenta.org/t/can-htm-predict-previous-inputs/5597/10 "2019-03-12T12:04:33Z")

</div>

Thanks for the link to the “alternative sequence memory” topic - a very interesting discussion there.
