diff --git a/tests/unit/nupic/algorithms/sdr_classifier_test.py b/tests/unit/nupic/algorithms/sdr_classifier_test.py index 7a926933dd..d2061a9306 100644 --- a/tests/unit/nupic/algorithms/sdr_classifier_test.py +++ b/tests/unit/nupic/algorithms/sdr_classifier_test.py @@ -24,6 +24,7 @@ import cPickle as pickle import random +import sys import tempfile import types import unittest2 as unittest @@ -788,6 +789,16 @@ def testMultiStepPredictions(self): self.assertAlmostEqual(result2[0][1], 1.0, places=1) + def testSoftMaxOverflow(self): + """ + Test if the softmax normalization overflows + """ + c = SDRClassifier([1], 1.0, 0.1, 0) + weight = numpy.array([[sys.float_info.max_exp + 1]]) + res = c.inferSingleStep([0], weight) + self.assertFalse(numpy.isnan(res), "SoftMax overflow") + + def _doWriteReadChecks(self, computeBeforeSerializing): c1 = SDRClassifier([0], 0.1, 0.1, 0)