Skip to content

Instantly share code, notes, and snippets.

@motokiee
Created January 12, 2017 14:43
Show Gist options
  • Save motokiee/9131f8768be0bf9c17d042cb0cf6952e to your computer and use it in GitHub Desktop.
Save motokiee/9131f8768be0bf9c17d042cb0cf6952e to your computer and use it in GitHub Desktop.
import numpy as np
def soft_max(a):
c = np.max(a)
exp_a = np.exp(a-c)
sum_exp_a = np.sum(exp_a)
y = exp_a / sum_exp_a
return y
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment