Created
July 4, 2016 06:54
-
-
Save nad2000/6100df204946da558212203ce401dffa to your computer and use it in GitHub Desktop.
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
"""Softmax.""" | |
scores = [3.0, 1.0, 0.2] | |
import numpy as np | |
def softmax(x): | |
"""Compute softmax values for each sets of scores in x.""" | |
exp_x = np.exp(x) | |
return exp_x / exp_x.sum(axis=0) | |
print(softmax(scores)) | |
# Plot softmax curves | |
import matplotlib.pyplot as plt | |
x = np.arange(-2.0, 6.0, 0.1) | |
scores = np.vstack([x, np.ones_like(x), 0.2 * np.ones_like(x)]) | |
plt.plot(x, softmax(scores).T, linewidth=2) | |
plt.show() |
Author
nad2000
commented
Feb 26, 2021
via email
Sorry man! I wish I remembered what was about and how found it, it was over
5 years ago...
…On Fri, 26 Feb 2021 at 12:17, MOHAMMAD KASID KHAN ***@***.***> wrote:
***@***.**** commented on this gist.
------------------------------
I know this is not the right place but I am unable to find any
documentation to learn more about softmax(scores).T in plt.plot(x,
softmax(scores).T, linewidth=2). Any help will be appreciated.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<https://gist.github.com/6100df204946da558212203ce401dffa#gistcomment-3645847>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AABLI4SQFYJGLJ4AAF3E46TTA3K7JANCNFSM4YHMZKCQ>
.
Thank you @nad2000 for your reply. In case someone comes here looking for the same answer, this what I found and helped me to clarify my doubt. https://stackoverflow.com/questions/5741372/syntax-in-python-t
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment