Conversation
spatial anomaly ported from NAB
had to exptend SP.compute(..., value=Real) with an optional argument
| << "Deterministic output of Anomaly failed! " << an << "should be: " << goldAn; | ||
| NTA_CHECK(static_cast<UInt>(avgAnom10.getCurrentAvg() * 10000.0f) == static_cast<UInt>(goldAnAvg * 10000.0f)) | ||
| << "Deterministic average anom score failed:" << avgAnom10.getCurrentAvg() << " should be: " << goldAnAvg; | ||
| if(useSPglobal) { NTA_CHECK(0.0f == spGlobal.anomaly) << "Deterministic spatial anomaly mismatch!" << spGlobal.anomaly; } |
There was a problem hiding this comment.
hotgym checks the new spatial anomaly
| virtual void compute(const SDR &input, | ||
| const bool learn, | ||
| SDR &active, | ||
| const Real spatialAnomalyInputValue = std::numeric_limits<Real>::min()); |
There was a problem hiding this comment.
had to extend SP.compute() with the extra, optional field. It works ok, but I don't like it too much, maybe better is the proposal with "SP carrying orig input value"?
There was a problem hiding this comment.
Maybe the anomaly code could be built into the encoder, since the encoder already has access to the original input value?
Alternatively, this piece of code (spatial anomaly detection) could live in its own class?
There was a problem hiding this comment.
anomaly code could be built into the encoder, since the encoder already has access to the original input value?
makes sense! This is really more a function of an encoder (input). As I was saying, I don't really like the current implementation, but it is what's used in NAB.
spatial anomaly detection) could live in its own class?
later I'm going to implement SP's anomaly detection based on synapses of SP, so
- a part of this PR was preparation of the "infrastructure" for the SP.anomaly, later I'd just change the actual method
- you're right this belongs more to the BaseEncoder than to SP
Which way would you suggest, I don't really have a preference now
| * | ||
| * @return either 0.0f (no anomaly), or exactly 0.9995947141f (spatial anomaly). This specific value can be recognized in results. | ||
| */ | ||
| const Real& anomaly = spAnomaly.anomalyScore_; |
There was a problem hiding this comment.
spAnomaly implementation,
| val = 100.0f; //(12-0) * 0.2 == ~2.2 -> <-2.2, +14.2> is not anomalous, but 100 is! | ||
| enc.encode(val, inputs); | ||
| sp.compute(inputs, true, columns, val); | ||
| EXPECT_EQ(0.9995947141f, sp.anomaly) << "This should be an anomaly!"; |
There was a problem hiding this comment.
testing SP.anomaly correctness
| return self.anomaly; | ||
| }); | ||
| py_SpatialPooler.def("anomalyThreshold", [](const SpatialPooler& self) { | ||
| return &self.spAnomaly.SPATIAL_TOLERANCE; |
There was a problem hiding this comment.
added the py bindings. Will this work so that I'll be able to set through the variable, or is it just a getter?
|
@dkeeney a chance this has to do with the recent x64 changes?
I cannot reproduce it locally on x86_64 Linux, also other CI pass. |
|
Putting this on hold until htm-community/NAB#15 is resolved. |
SP.anomaly&SP.compute(..., Real spatialValue)with the optional argument for spatial anomaly (it designates the original input value)const Real& SDR.origValue