Time & SDR'S & Structures


Hi, I am new to HTM and Nupic, so be gentle with me,
I have several questions

  1. I have a time-stamp represent by a double.
    for example : 0.0005->0.0007->0.0008 etc’
    With which SDR I need to work? , and how my time stamp will represent?
  2. If I have an attribute with short values, how you recommended to represent him? (n & w),
    recommended SDR’s converter?
  3. When I work with other temporal networks (like LSTM etc’), I need to define the network structure like the number of layers, the number of neurons in every layers etc’, where I can find examples and good information about this issue for HTM.
  4. May you have any tutorial about the different SDR’s, how and when to use?

Thanks :slight_smile:

  1. A double could represent a timestamp in so many ways. What granularity of time are you trying to capture in your encoding? First you have to convert your doubles into a datetime, then convert that into a binary representation based upon what time semantics you want to encode. Have you see the datetime encoding episode of HTM School?
  2. Use a scalar encoder (By the way, you are saying things like “which SDR I need to work” and “recommended SDR’s converter”. I think the word you are looking for is encoder. You are talking about encoding scalar values into binary format so an HTM can process it. We call this encoding.)
  3. There is no hierarchy in HTM for anomaly detection today. When you talk about LSTM “layers” you are talking about layers in a deep learning hierarchy .There is none in this setup. All of today’s HTM anomaly detection capabilities are based on sequence memory happening in one layer of neocortex.
  4. Watch HTM School, there are several videos on SDRs and encoders.


Hii ,
First , thanks for your answers .

  1. regarding to my first question , I have sensors in process, the process begin at time 0 and the time stamps are continues incremental , I sampling the sensors in 50 HZ (so every time stamp increment with 0.02 sec) each process continue only for 100 sec . Time have meaning only as reference from the beginning of the process . After my clarification what is your recommendation ?
  2. Thank you for the correction , from now and forever only encoder! :smile:

3.If I have short (16 bit) number that can received all the span (0- 65,535) , in average ~9 bits are active , how you recommended to choice W and N ?
4. Another question , may you have any benchmark about the HTM performance (computation time) ? , Or may you have implementation for CUDA (GPU)?


Try using a continuous cyclic encoder as described here.

For NuPIC, I think you want a ScalarEncoder with periodic=true.


According to my problem description above, to which values you are recommended to set my W and N values ?

  1. In the time stamp feature (0 to 100 sec, 5000 different value) ?
  2. In the short value feature ?

May you have any formula ?



You should experiment, It depends on how heavily you want to weight the date with respect to the other data you are encoding. The more bits you use for the date encoding, the more prominence it will take in the input space.

Yes, a scalar encoder can handle all rational numbers. You can limit them to hole integers, see the document I linked earlier. Instructions are there.


After I see HTM school videos I come up with new questions

  1. If I have a counter of 32 bit that represents a time stamp, and I encode it by Cyclic Encoding, with N=500 and w=32, the maximum bucket I will have is 469, it’s mean that every ~ 469 samples will mapping to the same value (even if I use with periodic =true) ,I am right ? , it’s also mean that value that has no connection will map to the same bucket …
  2. How I define the magic number N and W? there any formula to calculate the number of bits in output as a function of the input value (input length in bits , active bits in average etc’)?
  3. How N and W as input value influence on the HTM model? (why not set N to maximum ?