Last active
February 24, 2017 20:52
-
-
Save sethbunke/196d247d308a88fce793865938ee521f to your computer and use it in GitHub Desktop.
Understanding Softmax Function
This file contains 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
#Concise implementation | |
def softmax(inputs): | |
return np.exp(inputs) / np.sum(np.exp(inputs)) | |
#Verbose implementation (for clarification/understanding) | |
def softmax_verbose(inputs): | |
results = [np.exp(x) for x in inputs] | |
summation = sum(results) | |
probabilities = [(x / summation) for x in results] | |
return probabilities |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment