-
Notifications
You must be signed in to change notification settings - Fork 75
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
Anomaly score calculation separated to own function #739
Anomaly score calculation separated to own function #739
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Zbysekz code-wise the PR is good, a small change below
I'm somewhat reluctant to this change, as it mixes in Anomaly functionality into TM, which should have stayed separated,
TM.anomaly
is a convenience and only works (as stated in doc) if you usecompute() only
in your code- for other scenarios you're on your own and have
Anomaly
,AnomalyLikelihood
classes at your service (with full customization)
So the possible outcomes I see:
- rejecting the PR and using an instance of anomaly yourself (imho clearer design, unless too much extra code?)
- some compromise and making this function private in c++, and being more benevolent in py and exposing it there.
What do you think about this, conceptually? Or do you see a better way?
What I'll definitely like is the separation to a (private) method. The question is about exposing the functionality to outside world.
|
Well i just did it this way because it was easier way. I will modify this function according to your comments & delete pybind. But you are right, that we shouldn't mix TM and Anomaly. |
for c++ we have in
in python:
So:
|
alternatively, only write the class in pure python, it should be quite easy implementation with numpy or SDR |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So as discussed:
- keep the separate c++ function, but make it private
- implement Anomaly for python, either as bindings, or as a pure python code
- and remove the bindings for TM related to anomaly in this PR
- optional: bindings for Likelihood (already pure python impl exists) + help verifying/fixing the c++ implementation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this one change and this looks good.
Will you want to address the py/bindings for anomaly as a part of this PR too?
I will let you know, i think i will create anomaly calculation in pure python - at the end it is just simple calculation. I don't think that for one simple function is the effort of creating binding reasonable. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few comments on the new Anomaly py implementation, please have a look below
@breznak I commited this just because i am switching from laptop to desktop PC and i am now being interrupted often (my 2month old son :) ) so this is not yet to be merged, but i take your suggestions |
ok, seemed to me somehow half-aced.. ;) Enjoy the time with the baby! |
@breznak thanks. Maybe you can help me, suddenly when i compile htm.core i get error "Python.h" no such file or directory .. i know that this is related to missing python-dev (or python3-dev) but i have this installed... and previously it the compilation was successfull, do you have any advice?
|
try removing the |
ready to merge |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good, a few changes below, the biggest concern is
- does not work for multi-dimensional TM/SP,
Ok, now should be like you suggested |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This does look good now, thank you!
Please verify the 2 remaining concerns below and we're good to merge
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the improvements, let's merge this!
Thank you for this contribution, @Zbysekz 👍
I've just moved anomaly score calculation in TemporalMemory::compute function to separate function and enriched py bindings by binding to that function.
I need this, to be able to calculate anomaly score if i am calling activateDendrites and activateCells separately as discussed briefly in #658