Sequence Learning in HTM (repetitive numbers)

My program is learning distinct sequence from 9 to 0(9,8,7,6,5,4,3,2,1,0) and can predict it(eg when i/p is 9, it predicts 8, when i/p is 8 it predicts 7 and so on). I want my program to learn this sequence (9,8,7,6,5,9,8,7,6,4) and be able to predict it. Here, there are two possible numbers that proceed 6, (5 and 4). But my program is only predicting 5 after 6 and not 4 after 6. I have set 460 cycles for it to learn.
when I take distinct numbers like from 9 to 0, it learns in 8th cycle a 100% ( can predict all values from 9 to 0). But not for the second sequence. What parameters should be changed to achieve this?

Try to embed a counter as a categorical or binary predictor. When that counter is 0 then the prediction should be 5, and when it is 1 then the prediction should be 4.

Of course, that counter must be reset to 0 if it becomes 1.

For example, suppose i/p is 6 and the initial state of the counter is zero, then o/p should be 5. Once it produces 5, the counter should be updated to be 1. Now, if i/p is 6, the algorithm will check the counter again. Because it is now 1 not 0, so o/p should be 4. Once it produces 4, the counter should be rest to zero again. Continue…

Mathematically, it is like the following:
if i/p == 6:
o/p = i/p + (-1)^c
else
o/p = i/p - 1
end

where c is the state of the counter, which is either 0 or 1

One easy fix is to reduce the overlap between 5 and 4 SDR representations (Generated by the scalar encoder).

1 Like

Thank you for your comment. Can you please tell me how to reduce this overlap b/w 5 and 4 ?
By reducing the no of active bits for an input (w) and increasing the no of bits/window size?

Set the resolution in the scalar encoder to a low value. Yep, you need to increase n and decrease w.
Note:
1- Make sure that W is no less than 21.
2- More details can be found here:
https://nupic.docs.numenta.org/1.0.3/api/algorithms/encoders.html

1 Like

For which 6 in the sequence? I should only predict 5 for the first 6, and only predict 4 after the second 6 (after it has learned the sequence, that is).

If you were to train on (9,8,7,6,5,4,3,2,1,0) for a long time, when it sees 6 it will always predict 5. Now if you train the same model that is still learning on a second sequence of (9,8,7,6,4,4,3,2,1,0) for the same amount of time, then give it a 6 and it will predict both 5 and 4.

Thanks for the reply sir.
I am giving one sequence only as input.
That is (98765 98764) for the 500 cycles. But every time my program predicts 5 after 6 and not 4 after 6.
Any ideas which parameters should I alter or whats the way to learn sequence which have repetition of 2 or more numbers ?

What HTM implementation are you using?

I am using simple sequence experiment using scalar encoder. N parameters i am setting are :-
Cells per column =10
W= 21
N=400
So my program is just predicting correct sequence(9876598764) for 4 cycles in the 400 cycles(eg 15th, 134th, 210, 216th cycle), but for rest of the cycles it doesn’t predict 4 after 6. What should I do to fix this ?

I have set the following ,
Cells per column =10
W= 21
N=400
So my program is just predicting correct sequence(9876598764) for 4 cycles in the 400 cycles(eg 15th, 134th, 210, 216th cycle), but for rest of the cycles it doesn’t predict 4 after 6. What should I do to fix this ?

Maybe fiddle with the permanence increment / decrement TM? parameters? I think they’re both set to 0.1 by default, maybe if the dec was 0.05 instead it’d help.

What are your sequences exactly? Just repeating:

‘9,8,7,6,5,9,8,7,6,4’

for 400 cycles?