Problem with getFirstOnBit and season enconder


#1

when i run the hierarchy-demo, this issue will occure after some time, at begaining, it can work, but some hours, like 4 hours later, it will cannt work.
uninstall nupic cannt solve this problem, but uninstall annconda and re-install can solve, but will occure again.
what’s the reason, i’m trying to set season enconder’s maxval

runfile('D:/Documents/Desktop/Delta model2.py', wdir='D:/Documents/Desktop')
Creating network
Running network
Writing output to: D:/Documents/Desktop\hierarchy-demo-output.csv
Traceback (most recent call last):

  File "<ipython-input-4-c7a7de638576>", line 1, in <module>
    runfile('D:/Documents/Desktop/Delta model2.py', wdir='D:/Documents/Desktop')

  File "C:\ProgramData\Anaconda2\lib\site-packages\spyder\utils\site\sitecustomize.py", line 710, in runfile
    execfile(filename, namespace)

  File "C:\ProgramData\Anaconda2\lib\site-packages\spyder\utils\site\sitecustomize.py", line 86, in execfile
    exec(compile(scripttext, filename, 'exec'), glob, loc)

  File "D:/Documents/Desktop/Delta model2.py", line 445, in <module>
    runDemo()

  File "D:/Documents/Desktop/Delta model2.py", line 439, in runDemo
    runNetwork(network, numRecords, writer)

  File "D:/Documents/Desktop/Delta model2.py", line 369, in runNetwork
    network.run(1)

  File "C:\ProgramData\Anaconda2\lib\site-packages\nupic\engine\__init__.py", line 667, in run
    engine_internal.Network.run(self, n)

  File "C:\ProgramData\Anaconda2\lib\site-packages\nupic\bindings\engine_internal.py", line 1534, in run
    return _engine_internal.Network_run(self, n)

  File "C:\ProgramData\Anaconda2\lib\site-packages\nupic\bindings\regions\PyRegion.py", line 184, in guardedCompute
    return self.compute(inputs, DictReadOnlyWrapper(outputs))

  File "C:\ProgramData\Anaconda2\lib\site-packages\nupic\regions\record_sensor.py", line 377, in compute
    self.encoder.encodeIntoArray(data, outputs["dataOut"])

  File "C:\ProgramData\Anaconda2\lib\site-packages\nupic\encoders\multi.py", line 100, in encodeIntoArray
    encoder.encodeIntoArray(self._getInputValue(obj, name), output[offset:])

  File "C:\ProgramData\Anaconda2\lib\site-packages\nupic\encoders\date.py", line 382, in encodeIntoArray
    encoder.encodeIntoArray(scalars[i], output[offset:])

  File "C:\ProgramData\Anaconda2\lib\site-packages\nupic\encoders\scalar.py", line 426, in encodeIntoArray
    bucketIdx = self._getFirstOnBit(input)[0]

  File "C:\ProgramData\Anaconda2\lib\site-packages\nupic\encoders\scalar.py", line 366, in _getFirstOnBit
    (str(input), str(self.minval), str(self.maxval)))

Exception: input (300) greater than periodic range (0 - 300)

#2

What is this “hierarchy-demo”? I don’t see any example source code in our repository with that name. If it is a script that you’ve written, can you describe what you are doing or share the code? Is the computer running out of memory or disk space?


#3

I’m running the hierarchy_network_demo.py, and change the maxval of seasonencoder, my purpuse is to change it more easily.
but after some hours, the mistake will appear

 self.seasonEncoder = None
    if season != 0:
      # Ignore leapyear differences -- assume 366 days in a year
      # Radius = 91.5 days = length of season
      # Value is number of days since beginning of year (0 - 355)
      if hasattr(season, "__getitem__"):
        w = season[0]
        radius = season[1]
        **maxvall = season[2]**
      else:
        w = season
        radius = 91.5

      self.seasonEncoder = ScalarEncoder(w = w, minval=0, **maxval=maxvall**,
                                         radius=radius, periodic=True,
                                         name="season", forced=forced)
      self.seasonOffset = self.width
      self.width += self.seasonEncoder.getWidth()
      self.description.append(("season", self.seasonOffset))
      self.encoders.append(("season", self.seasonEncoder, self.seasonOffset))

#4

What did you set maxval to? And what do you mean about your purpose? What are you trying to change more easily? The encoding? If you change the maxval it might not be doing seasonal encoding anymore. You’re changing the functionality of the encoder.


#5

Yes, I want to change the season encoder to a adjustable length season encoder.
and want use more than once with diffrent length at one multiencoder.
Is this possiable?


#6

Yes, it probably is possible, but you probably want to extend DateEncoder. Have your read our docs?


#7

Actually, I don’t think you need to subclass anything, just provide a tuple to the constructor for season to set your own encoding width and bucket radius.


#8

I try to change the maxval of seasonencoder, not the w, what’s the best solution? use scalaencoder directly?