Skip to content

Commit

Permalink
Fix softmax overflow
Browse files Browse the repository at this point in the history
  • Loading branch information
suzusuzu committed Mar 13, 2018
1 parent 9bb7705 commit 08daff4
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions src/nupic/algorithms/sdr_classifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 08daff4

Please sign in to comment.