Skip to content

Instantly share code, notes, and snippets.

@JimHaughwout
Created December 14, 2016 12:23
Show Gist options
  • Save JimHaughwout/38b310cb7e38b3fa232ca32a65105a07 to your computer and use it in GitHub Desktop.
Save JimHaughwout/38b310cb7e38b3fa232ca32a65105a07 to your computer and use it in GitHub Desktop.
Simple softmax implementation
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