Skip to content

Instantly share code, notes, and snippets.

@kcha4github
Created August 4, 2018 09:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kcha4github/1b625c7cd56ab79cd814d173deda40de to your computer and use it in GitHub Desktop.
Save kcha4github/1b625c7cd56ab79cd814d173deda40de to your computer and use it in GitHub Desktop.
import numpy as np
import matplotlib.pyplot as plt
def step_function(x):
return np.array(x > 0, dtype=np.int)
def sigmoid(x):
return 1 / (1 + np.exp(-x))
def relu(x):
return np.maximum(0, x)
x = np.arange(-5.0, 5.0, 0.1)
y1 = step_function(x)
y2 = sigmoid(x)
y3 = relu(x)
plt.plot(x, y1, x, y2, x, y3)
plt.legend(('step function', 'sigmoid', 'ReLU'))
#plt.plot(x, y1, label='step function')
#plt.plot(x, y2)
#plt.plot(x, y3)
plt.ylim(-0.1, 5.1) # define the range of y
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment