Hello.
In this source code: https://github.com/numenta/nupic/blob/master/src/nupic/encoders/scalar.py provided example for encoding week days:
monday (1) -> 11000000000001
tuesday(2) -> 01110000000000
wednesday(3) -> 00011100000000
...
sunday (7) -> 10000000000011
I looked at the source code and tried to write my own encoder, but it doesn’t work like in the example above:
monday (1) -> [1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]
uesday(2) -> [0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
wednesday(3) -> [0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0]
sunday (7) -> [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1]
Unfortunately, I can’t figure out what the problem is =(
How to achieve the result as in the example above?
Here is source of my encoder:
function encoder(min, max, val, n, w) {
const range = max - min
const centr = Math.round((val - min) * n / range)
const halfw = (w - 1) / 2
const start = centr - halfw < 0
? n + (centr - halfw)
: 0 + (centr - halfw)
const sdr = []
for (let i = 0; i < n; i++) {
sdr.push(0)
}
for (let i = start; i < start + w; i++) {
sdr[i % n] = 1
}
}
And you can run or edit it here:
Thank you!