Skip to content

Instantly share code, notes, and snippets.

@idleuncle
Created March 5, 2020 17:28
Show Gist options
  • Save idleuncle/d383866efd50461736e45850a2425c25 to your computer and use it in GitHub Desktop.
Save idleuncle/d383866efd50461736e45850a2425c25 to your computer and use it in GitHub Desktop.
softmax
def softmax(x):
e_x = np.exp(x - np.max(x, axis=1).reshape(-1, 1))
return e_x / e_x.sum(axis=1).reshape(-1, 1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment