Created
December 14, 2016 12:23
-
-
Save JimHaughwout/38b310cb7e38b3fa232ca32a65105a07 to your computer and use it in GitHub Desktop.
Simple softmax implementation
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 | |
from math import exp | |
def softmax(x): | |
"""Compute softmax values for each sets of scores in x.""" | |
# S(yi) = e^/yi / sum(ey2) | |
y = np.array(x) | |
f = np.vectorize(exp) | |
n = f(y) | |
d = sum(n) | |
return n / d |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment