Created
June 3, 2016 08:32
-
-
Save psycharo-zz/5d98951ccd43961e195980a77c7d4c71 to your computer and use it in GitHub Desktop.
N-dim softmax in numpy
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(x, axis=None): | |
| e_x = np.exp(x - np.max(x, axis=axis, keepdims=True)) | |
| return e_x / np.sum(e_x, axis=axis, keepdims=True) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment