From 08daff4a3e4d7823568c9ccf0ffedebe064c31d4 Mon Sep 17 00:00:00 2001 From: suzusuzu Date: Tue, 13 Mar 2018 06:31:02 +0900 Subject: [PATCH] Fix softmax overflow --- src/nupic/algorithms/sdr_classifier.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/nupic/algorithms/sdr_classifier.py b/src/nupic/algorithms/sdr_classifier.py index 2054811d3c..83bc21e031 100644 --- a/src/nupic/algorithms/sdr_classifier.py +++ b/src/nupic/algorithms/sdr_classifier.py @@ -374,6 +374,7 @@ def inferSingleStep(self, patternNZ, weightMatrix): outputActivation = weightMatrix[patternNZ].sum(axis=0) # softmax normalization + outputActivation = outputActivation - numpy.max(outputActivation) expOutputActivation = numpy.exp(outputActivation) predictDist = expOutputActivation / numpy.sum(expOutputActivation) return predictDist