Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
import numpy as np
import matplotlib.pyplot as plt
def step_function(x):
return np.array(x > 0,
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.