Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python examples fixes #713

Merged
merged 6 commits into from
Oct 8, 2019
Merged

Python examples fixes #713

merged 6 commits into from
Oct 8, 2019

Conversation

breznak
Copy link
Member

@breznak breznak commented Oct 7, 2019

Fixes #712

@@ -10,7 +10,7 @@
from htm.encoders.date import DateEncoder
from htm.bindings.algorithms import SpatialPooler
from htm.bindings.algorithms import TemporalMemory
from htm.algorithms.anomaly_likelihood import AnomalyLikelihood
from htm.algorithms.anomaly_likelihood import AnomalyLikelihood #FIXME use TM.anomaly instead, but it gives worse results than the py.AnomalyLikelihood now
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OT: this file is a good place to test and replace the python likelihood with TM.anomaly. Currently the Likelihood from TM (c++) really gives bad results. #665

py/htm/examples/hotgym.py Outdated Show resolved Hide resolved
instead of assertion, that makes processing pipelines easier.
@t0n8
Copy link

t0n8 commented Oct 8, 2019

    plt.plot(np.arange(len(inputs)), inputs, 'red',
             np.arange(len(inputs)), anomaly, 'blue',)

Line 232/233 throws the following error at this end:
ValueError: x and y must have same first dimension, but have shapes (4385,) and (4391,)

This seems to be a side effect from line 194
inputs = inputs[6:] #crop the first max prediction-steps inputs (as those don't have inferences)

So maybe line 232/233 should be changed to:

    plt.plot(np.arange(len(inputs)), inputs, 'red',
             np.arange(len(inputs)), anomaly[6:], 'blue',)

Would that make sense?

Copy link

@dkeeney dkeeney left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me.

@breznak
Copy link
Member Author

breznak commented Oct 8, 2019

This seems to be a side effect from line 194
inputs = inputs[6:] #crop the first max prediction-steps inputs (as those don't have inferences)

@t0n8 Are you reviewing up to date sources? a) that still shouldn't be a problem since both arrays have been cropped, b) the change is now gone with bb3808b

@breznak breznak merged commit 27c4559 into master Oct 8, 2019
@breznak breznak deleted the examples_fix branch October 8, 2019 20:42
@breznak
Copy link
Member Author

breznak commented Oct 8, 2019

Thank you for review, David
@t0n8 let us know if everything works, it should now

@t0n8
Copy link

t0n8 commented Oct 9, 2019

Hi @breznak,

Tried again and do get a different error:

ERR:  CHECK FAILED: "dimensions_ != 0" Classifier: must call `learn` before `infer`. [D:\a\htm.core\htm.core\src\htm\algorithms\SDRClassifier.cpp line 50]
Traceback (most recent call last):
  File "hotgym.py", line 240, in <module>
    main()
  File "hotgym.py", line 161, in main
    pdf = predictor.infer( tm.getActiveCells() )
RuntimeError: CHECK FAILED: "dimensions_ != 0" Classifier: must call `learn` before `infer`.

Now I am wondering, whether this has to do with the fact that I am using the updated hotgym.py code with the current binary release.

I'll give it another try, once a new binary has been released.

Sorry for any confusion this might have caused.

Sorry for any confusion.

@breznak
Copy link
Member Author

breznak commented Oct 9, 2019

whether this has to do with the fact that I am using the updated hotgym.py code with the current binary release.

yes, that would be the case. For now you'll need to build from source to get the fix (see Readme on how to do so), or wait till a new release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

AttributeError of SP getOverlaps
4 participants