Created
November 16, 2015 05:15
-
-
Save zhmz1326/5a6cad0eae9479205506 to your computer and use it in GitHub Desktop.
Draw sigmoid function by matplotlib
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
sigmoid = lambda x: 1 / (1 + np.exp(-x)) | |
x=linspace(-10,10,10) | |
y=linspace(-10,10,100) | |
plot(x,sigmoid(x),'r', label='linspace(-10,10,10)') | |
plot(y,sigmoid(y),'b', label='linspace(-10,10,100)') | |
grid() | |
xlabel('X Axis') | |
ylabel('Y Axis') | |
title('Sigmoid Function') | |
suptitle('Sigmoid') | |
text(4,0.8,r'$\sigma(x)=\frac{1}{1+e^{-x}}$',fontsize=15) | |
legend(loc='lower right') | |
gca().xaxis.set_major_locator(MultipleLocator(1)) | |
gca().yaxis.set_major_locator(MultipleLocator(0.1)) | |
legend(bbox_to_anchor=(0.5, -0.2), loc='center', borderaxespad=0) | |
subplots_adjust(bottom=0.22) | |
Author
zhmz1326
commented
Nov 16, 2015
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment