Created
October 19, 2019 10:25
-
-
Save claclacla/655679c28511fcb6d0de521f571d88da to your computer and use it in GitHub Desktop.
The softmax function implmentation in python
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
# Softmax function | |
# SF(M) = e(A[i]) / sum(e(A)) | |
# M: The given matrix | |
M = np.array([1, 2, 3]) | |
# Calculate the exponential of all elements in the input array | |
M = np.exp(M) | |
# Calculate the ratio of the exponential of the parameter and the sum of exponential parameter | |
M = M / np.sum(M) | |
print(M) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment