Debugging CoordinateEncoder issues in NuPIC 1.0


#1

Hi All(/Matt),

So I got nupic installed, though when I try to run my same run.py script I get:

Importerror: No module named clamodel

It seems that the upgrade to nupic 1.0 hasn’t fully taken effect, since ‘cla’ has been replaced with ‘HTMPrediction’ in all the new stuff right? I wonder if Spyder is still looking at the old nupic. Would the old nupic I had (0.5.7) be written over by nupic 1.0, or is it possible that both are there now? Thanks again!!


Example usage of Coordinate Encoder
Example usage of Coordinate Encoder
NuPIC 1.0.1 bugfix release
#2

I’ve been investigating… and it looks like usage of the CoordinateEncoder is broken in NuPIC 1.0.

I have a fix in a PR, but waiting for review. I will need to release a bugfix to fix this for pip installers.


#3

Ok I see. Thanks for investigating that! So I did switch my params file to go back to simple scalar values, though I’m still getting the error:

model = pickle.load(modelPickelFile)
Importerror: no module named clamodel

Which happens when I try to load a saved model, using:

model = Model.load(path)

(which worked previously). I know that ‘cla’ has been replaced in the new nupic, so this means that its still trying to use the old nupic, right? Should I go back and try to delete it all? I’m sorry about this!


#4

Are you trying to resurrect an old model saved in an older version of NuPIC? Because that will not work because we broke backwards compatibility:


#5

I think I was yes, so I deleted that old model and got past that error!
Now I’m running into this, saying it doesn’t recognize maxBoost as an SP param. Should I maybe replace it with ‘boostStrength’ or ‘stimulusThreshold’?

RuntimeError: Unknown parameter ‘maxBoost’ for region ‘SP’ of type ‘py.SPRegion’. Thanks again!


#6

This. But I must warn you that it will still fail, giving you an error like this:

  File "/Users/mtaylor/nta/nupic/src/nupic/encoders/base.py", line 351, in getBucketIndices
    assert False, "Should be implemented in base classes that are not " \
AssertionError: Should be implemented in base classes that are not containers for other encoders

Until we get that bug fixed.


#7

Hmm it actually worked ok! It ran when I used my scalar valued input, but when I tried with the coordinate encoder the kernel died, failing on this line:

inputData = “%s/%s.csv” % (DATA_DIR, file_name.replace(" ", “_”))

after it printed:

Creating model from…

Should I basically sit tight until that base class bug is fixed, and then reinstall (or update however) at that point? Thanks again!


#8

That is an unexpected error… That is coming from your own code, is it not?


#9

Ok I got through the kernel dying issue, and am now face to face with the error you predicted before:

I think this means that my update to 1.0.1 hasn’t worked then, cause that version is the only one that shouldn’t hit this snag, right? We’re getting so close I can feel it!!


#10

Yes, I think you’re right. Do this to find out what version you have installed.


#11

Here’s the result:

nupic 1.0.1
nupic.bindings 1.0.0

Does bindings need to be 1.0.1 you think?


#12

You may have two versions of it installed. Try to manually remove those old installs if you can.


#13

Ok, that’s good to hear! I am still encountering this error and I have a hunch why. I notice that it’s getting ‘htm_prediction_model.py’ from:

‘/usr/local/lib/python2.7/dist-packages/nupic/frameworks/opf/’

Whereas that folder within the new nupic is located here:

‘/home/sheiser1/nupic/frameworks/opf’

There’s also the fact that the ‘2d_run_new.py’ script I’m running was created in the older version of nupic. Might I need to change the current directory within that do you think? You’re really the man for tolerating this!!

Traceback (most recent call last):
File “2D_run_new.py”, line 275, in
runModel(only_csv_files,train_files,test_files,plot=plot)
File “2D_run_new.py”, line 253, in runModel
runIoThroughNupic(inputData, model, file_name, plot)
File “2D_run_new.py”, line 207, in runIoThroughNupic
result = model.run(modelInput)

File “/usr/local/lib/python2.7/dist-packages/nupic/frameworks/opf/htm_prediction_model.py”, line 441, in run
inferences = self._multiStepCompute(rawInput=inputRecord)
File “/usr/local/lib/python2.7/dist-packages/nupic/frameworks/opf/htm_prediction_model.py”, line 597, in _multiStepCompute
rawInput=rawInput)
File “/usr/local/lib/python2.7/dist-packages/nupic/frameworks/opf/htm_prediction_model.py”, line 790, in _handleSDRClassifierMultiStep
bucketIdx = self._classifierInputEncoder.getBucketIndices(absoluteValue)[0]
File “/usr/local/lib/python2.7/dist-packages/nupic/encoders/base.py”, line 351, in getBucketIndices

assert False, "Should be implemented in base classes that are not " \

AssertionError: Should be implemented in base classes that are not containers for other encoders

:vulcan_salute:


#14

I am still puzzled by this conversation. For me upgrading to nupic1.01 enabled me to get my encoder subclass of coordinateEncoder working as I expected. But I am now facing the same issue and the same error message as this.
File “/home/brian/.virtualenvs/nu101/local/lib/python2.7/site-packages/nupic/encoders/base.py”, line 351, in getBucketIndices
assert False, "Should be implemented in base classes that are not "
AssertionError: Should be implemented in base classes that are not containers for other encoders

To me this means that my encoder, or coordinateEncoder if you are not subclassing it, need to have their own getBucketIndices() function! But what puzzles me more is how to write it. I can’t see how the buckets used in the encoder relate to the labels used for the inputData.

I keenly await the thoughts of sheiser1 and rhyolite.


#15

Are you trying to generate predictions of the next coordinate? Because that won’t work. You can only get anomaly indications at this point.


#16

All I want is the anomaly score. But which model will give anomaly score without predictions? I’ve tried the line by line example in the lastest docs. I’ve also tried temporal_anomaly_network_demo to no avai (among others)l. I have tried the temporal_anomaly option of the parameters.
In some ways this does not matter. For my special needs I have been able to write a 2D coordinate encoder subclassed from scalarEncoder. If it tests out OK then problem solved for me. It has the advantage that prediction should be possible, even though constrained to a limited regular grid.


#17

That is strange. I don’t know why you’re getting this error. Can you include the entire stack trace?


#18

Well here’s mine, I wonder if its about the same. I just uninstalled nupic and reinstalled, to make sure I’m up to 1.0.1

Traceback (most recent call last):

File “2D_run_new.py”, line 275, in
runModel(only_csv_files,train_files,test_files,plot=plot)
File “2D_run_new.py”, line 253, in runModel
runIoThroughNupic(inputData, model, file_name, plot)
File “2D_run_new.py”, line 207, in runIoThroughNupic
result = model.run(modelInput)

File “/usr/local/lib/python2.7/dist-packages/nupic/frameworks/opf/htm_prediction_model.py”, line 441, in run
inferences = self._multiStepCompute(rawInput=inputRecord)
File “/usr/local/lib/python2.7/dist-packages/nupic/frameworks/opf/htm_prediction_model.py”, line 597, in _multiStepCompute
rawInput=rawInput)
File “/usr/local/lib/python2.7/dist-packages/nupic/frameworks/opf/htm_prediction_model.py”, line 790, in _handleSDRClassifierMultiStep
bucketIdx = self._classifierInputEncoder.getBucketIndices(absoluteValue)[0]
File “/usr/local/lib/python2.7/dist-packages/nupic/encoders/base.py”, line 351, in getBucketIndices
assert False, "Should be implemented in base classes that are not "
AssertionError: Should be implemented in base classes that are not containers for other encoders


Example usage of Coordinate Encoder
#19

For just a little more context here’s part of my runIOThroughNupic() function:

modelInput = {
“vector”: (vector,radius)
}

result = model.run(modelInput)

if counter % 100 == 0:
  print ("Read %i lines..." % counter)
  

if plot:
  result = shifter.shift(result)

#prediction = result.inferences["multiStepBestPredictions"][1]
anomalyScore = result.inferences["anomalyScore"]
output.write('_____', y_response, '_____', anomalyScore) #[timestamp]

As you can see I commented out the 'prediction = ’ line, since I know we can only get anomaly scores and not predictions. In this case the vector is something like [5,7] and the radius something like 2. Any hunches?


Example usage of Coordinate Encoder
#20

I’m working on it.