Created
August 4, 2018 09:26
-
-
Save kcha4github/1b625c7cd56ab79cd814d173deda40de to your computer and use it in GitHub Desktop.
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
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