Created
January 8, 2018 02:31
-
-
Save ricklentz/292d684bd1023d99d84b81beb5750120 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
def softmax(L): | |
expL = np.exp(L) | |
sumExpL = sum(expL) | |
result = [] | |
for i in expL: | |
result.append(i*1.0/sumExpL) | |
return result | |
# Note: The function np.divide can also be used here, as follows: | |
# def softmax(L): | |
# expL(np.exp(L)) | |
# return np.divide (expL, expL.sum()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment