def compute(self, inputs, outputs):
<EOL>if self._useAuxiliary is None:<EOL><INDENT>self._useAuxiliary = False<EOL><DEDENT>if self._firstComputeCall:<EOL><INDENT>self._firstComputeCall = False<EOL>if self._useAuxiliary:<EOL><INDENT>if self._justUseAuxiliary == True:<EOL><INDENT>print("<STR_LIT>")<EOL><DEDENT><DEDENT><DEDENT>inputVector = inputs['<STR_LIT>']<EOL>if self._useAuxiliary==True:<EOL><INDENT>auxVector = inputs['<STR_LIT>']<EOL>if auxVector.dtype != numpy.float32:<EOL><INDENT>raise RuntimeError("<STR_LIT>")<EOL><DEDENT>if self._justUseAuxiliary == True:<EOL><INDENT>inputVector = inputs['<STR_LIT>']<EOL><DEDENT>else:<EOL><INDENT>inputVector = numpy.concatenate([inputVector, inputs['<STR_LIT>']])<EOL><DEDENT><DEDENT>self.handleLogInput([inputVector])<EOL>assert "<STR_LIT>" in inputs, "<STR_LIT>"<EOL>categories = inputs['<STR_LIT>']<EOL>if "<STR_LIT>" in inputs:<EOL><INDENT>assert len(inputs["<STR_LIT>"]) == <NUM_LIT:1>, "<STR_LIT>"<EOL>partInput = inputs['<STR_LIT>']<EOL>assert len(partInput) == <NUM_LIT:1>, "<STR_LIT>"<EOL>partition = int(partInput[<NUM_LIT:0>])<EOL><DEDENT>else:<EOL><INDENT>partition = None<EOL><DEDENT>if self.inferenceMode:<EOL><INDENT>categoriesOut = outputs['<STR_LIT>']<EOL>probabilitiesOut = outputs['<STR_LIT>']<EOL>if self._doSphering:<EOL><INDENT>inputVector = (inputVector + self._normOffset) * self._normScale<EOL><DEDENT>nPrototypes = <NUM_LIT:0><EOL>if "<STR_LIT>" in outputs:<EOL><INDENT>bestPrototypeIndicesOut = outputs["<STR_LIT>"]<EOL>nPrototypes = len(bestPrototypeIndicesOut)<EOL><DEDENT>winner, inference, protoScores, categoryDistances =self._knn.infer(inputVector, partitionId=partition)<EOL>if not self.keepAllDistances:<EOL><INDENT>self._protoScores = protoScores<EOL><DEDENT>else:<EOL><INDENT>if self._protoScores is None:<EOL><INDENT>self._protoScores = numpy.zeros((<NUM_LIT:1>, protoScores.shape[<NUM_LIT:0>]),<EOL>protoScores.dtype)<EOL>self._protoScores[<NUM_LIT:0>,:] = protoScores<EOL>self._protoScoreCount = <NUM_LIT:1><EOL><DEDENT>else:<EOL><INDENT>if self._protoScoreCount == self._protoScores.shape[<NUM_LIT:0>]:<EOL><INDENT>newProtoScores = numpy.zeros((self._protoScores.shape[<NUM_LIT:0>] * <NUM_LIT:2>,<EOL>self._protoScores.shape[<NUM_LIT:1>]),<EOL>self._protoScores.dtype)<EOL>newProtoScores[:self._protoScores.shape[<NUM_LIT:0>],:] = self._protoScores<EOL>self._protoScores = newProtoScores<EOL><DEDENT>self._protoScores[self._protoScoreCount,:] = protoScores<EOL>self._protoScoreCount += <NUM_LIT:1><EOL><DEDENT><DEDENT>self._categoryDistances = categoryDistances<EOL>if self.outputProbabilitiesByDist:<EOL><INDENT>scores = <NUM_LIT:1.0> - self._categoryDistances<EOL><DEDENT>else:<EOL><INDENT>scores = inference<EOL><DEDENT>total = scores.sum()<EOL>if total == <NUM_LIT:0>:<EOL><INDENT>numScores = len(scores)<EOL>probabilities = numpy.ones(numScores) / numScores<EOL><DEDENT>else:<EOL><INDENT>probabilities = scores / total<EOL><DEDENT>nout = min(len(categoriesOut), len(inference))<EOL>categoriesOut.fill(<NUM_LIT:0>)<EOL>categoriesOut[<NUM_LIT:0>:nout] = inference[<NUM_LIT:0>:nout]<EOL>probabilitiesOut.fill(<NUM_LIT:0>)<EOL>probabilitiesOut[<NUM_LIT:0>:nout] = probabilities[<NUM_LIT:0>:nout]<EOL>if self.verbosity >= <NUM_LIT:1>:<EOL><INDENT>print("<STR_LIT>", categoriesOut[<NUM_LIT:0>:nout])<EOL>print("<STR_LIT>", probabilitiesOut[<NUM_LIT:0>:nout])<EOL><DEDENT>if self._scanInfo is not None:<EOL><INDENT>self._scanResults = [tuple(inference[:nout])]<EOL><DEDENT>for category in categories:<EOL><INDENT>if category >= <NUM_LIT:0>:<EOL><INDENT>dims = max(int(category)+<NUM_LIT:1>, len(inference))<EOL>oldDims = len(self.confusion)<EOL>if oldDims < dims:<EOL><INDENT>confusion = numpy.zeros((dims, dims))<EOL>confusion[<NUM_LIT:0>:oldDims, <NUM_LIT:0>:oldDims] = self.confusion<EOL>self.confusion = confusion<EOL><DEDENT>self.confusion[inference.argmax(), int(category)] += <NUM_LIT:1><EOL><DEDENT><DEDENT>if nPrototypes > <NUM_LIT:1>:<EOL><INDENT>bestPrototypeIndicesOut.fill(<NUM_LIT:0>)<EOL>if categoryDistances is not None:<EOL><INDENT>indices = categoryDistances.argsort()<EOL>nout = min(len(indices), nPrototypes)<EOL>bestPrototypeIndicesOut[<NUM_LIT:0>:nout] = indices[<NUM_LIT:0>:nout]<EOL><DEDENT><DEDENT>elif nPrototypes == <NUM_LIT:1>:<EOL><INDENT>if (categoryDistances is not None) and len(categoryDistances):<EOL><INDENT>bestPrototypeIndicesOut[<NUM_LIT:0>] = categoryDistances.argmin()<EOL><DEDENT>else:<EOL><INDENT>bestPrototypeIndicesOut[<NUM_LIT:0>] = <NUM_LIT:0><EOL><DEDENT><DEDENT>self.handleLogOutput(inference)<EOL><DEDENT>if self.learningMode:<EOL><INDENT>if (self.acceptanceProbability < <NUM_LIT:1.0>) and(self._rgen.getReal64() > self.acceptanceProbability):<EOL><INDENT>pass<EOL><DEDENT>else:<EOL><INDENT>for category in categories:<EOL><INDENT>if category >= <NUM_LIT:0>:<EOL><INDENT>if self._doSphering:<EOL><INDENT>self._storeSample(inputVector, category, partition)<EOL><DEDENT>else:<EOL><INDENT>self._knn.learn(inputVector, category, partition)<EOL><DEDENT><DEDENT><DEDENT><DEDENT><DEDENT>self._epoch += <NUM_LIT:1><EOL>
Process one input sample. This method is called by the runtime engine.

.. note:: the number of input categories may vary, but the array size is 
   fixed to the max number of categories allowed (by a lower region), so 
   "unused" indices of the input category array are filled with -1s.

TODO: confusion matrix does not support multi-label classification

:param inputs: (dict) mapping region input names to numpy.array values
:param outputs: (dict) mapping region output names to numpy.arrays that 
       should be populated with output values by this method