Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import numpy as np
- import matplotlib.pyplot as plt
- x = np.arange(-5,5,0.01)
- def relu(x):
- return [i if i>0 else 0 for i in x]
- def softmax(x):
- return np.exp(x) / np.sum(np.exp(x))
- def sigmoid(x):
- return 1/(1+np.exp(-x))
- def tanh(x):
- return (np.exp(x)-np.exp(-x))/(np.exp(x)+np.exp(-x))
- soft = softmax([[1,2,3],[4,5,6]])
- print(soft)
- plt.plot(x,relu(x),'b')
- plt.plot(x,sigmoid(x),'r')
- plt.plot(x,tanh(x),'g')
- plt.legend(["RelU","Softmax","sigmoid","tanh"])
- plt.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement