Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from matplotlib import pyplot as plt
- import numpy as np
- import math
- def ReLU(x):
- return np.maximum(0, x)
- def Sigmoid(x):
- return 1.0 / (1 + np.exp(-x))
- def Softmax(x):
- expo = np.exp(x)
- expo_sum = np.sum(np.exp(x))
- return expo/expo_sum
- def Tanh(x):
- a = np.exp(x) - np.exp(-x)
- b = np.exp(x) + np.exp(-x)
- return a/b
- d = 5
- x = np.arange(-d, d, step=0.1)
- plt.plot(x, ReLU(x), color='red', label='ReLU')
- plt.plot(x, Sigmoid(x), color='green', label='Sigmoid')
- plt.plot(x, Tanh(x), color='blue', label='Tanh')
- plt.grid()
- plt.legend()
- plt.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement