Skip to content

Instantly share code, notes, and snippets.

@zhmz1326
Created November 16, 2015 05:15
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save zhmz1326/5a6cad0eae9479205506 to your computer and use it in GitHub Desktop.
Save zhmz1326/5a6cad0eae9479205506 to your computer and use it in GitHub Desktop.
Draw sigmoid function by matplotlib
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)
@zhmz1326
Copy link
Author

figure_1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment