Skip to content
This repository has been archived by the owner on Sep 1, 2023. It is now read-only.

NUP-2396: Allow SensorRegion to pass actValue and bucketIdx to SDRClassifierRegion #3526

Merged
merged 5 commits into from
Apr 14, 2017

Conversation

marionleborgne
Copy link
Member

@marionleborgne marionleborgne commented Apr 8, 2017

This PR blocks #3520.

The network API does not support continuous inference at the moment. The workaround has been to call customCompute() on the classifier region to do inference.

This PR fixes the issue: the change enables the creation of new links between sensor and classifier regions so that the SensorRegion can pass bucketIdx and actValue to the SDRClassifierRegion. This way inference can happen within the network, without having to call customCompute() in an outer loop.

@marionleborgne
Copy link
Member Author

cc @scottpurdy and @rhyolight

Copy link
Contributor

@scottpurdy scottpurdy left a comment

Choose a reason for hiding this comment

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

Done reviewing!

if self.predictedFieldIdx > 0:
fields = self.dataSource.getFieldNames()
if self.predictedFieldIdx >= len(fields):
raise ValueError("predictedFieldIdx (%s) must be strictly inferior "
Copy link
Contributor

Choose a reason for hiding this comment

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

"strictly inferior to the" -> "strictly less than the"

@@ -381,6 +402,22 @@ def compute(self, inputs, outputs):
learn=self.learningMode,
infer=False)

# If the input does not belong to a category, i.e. len(categories) == 0,
# then look for bucketIdx and ActValueIn.
Copy link
Contributor

Choose a reason for hiding this comment

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

ActValueIn -> actValueIn

if len(categories) == 0:
if "bucketIdxIn" not in inputs:
raise KeyError("Network link missing: bucketIdxOut -> bucketIdxIn")
if "actValue" not in inputs:
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't this be "actValueIn"?

Copy link
Member Author

Choose a reason for hiding this comment

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

Good catch, thanks!

@scottpurdy
Copy link
Contributor

Also, can you include a test that exercises this behavior? One of my comments is on a line that looks like a bug so a test would help make sure all of this works as expected.

@marionleborgne
Copy link
Member Author

Thanks for the review @scottpurdy

To answer #3526 (comment), the "test" I am using to check that the new links work lives in this PR: #3520

Test usage: cd nupic/docs/examples/util; python check_predictions.py to generate predictions on the Hot Gym dataset with OPF, network API, and research API. This compares the RMSE of the predictions for the 3 frameworks.

Would you rather have a unit test in nupic?

@scottpurdy
Copy link
Contributor

Yes, a unit test with a simple network that exercises the new functionality would be great. It could be an sdr classifier unit test.

@marionleborgne
Copy link
Member Author

@scottpurdy thanks for the review. I integrated the feedback and also added unit tests. It's ready for review again.

@marionleborgne
Copy link
Member Author

Fixes #3547

@scottpurdy scottpurdy merged commit 3494ff0 into numenta:master Apr 14, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants