Advertisement
Guest User

Untitled

a guest
Dec 10th, 2019
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.51 KB | None | 0 0
  1. import numpy as np
  2. import matplotlib.pyplot as plt
  3.  
  4.  
  5.  
  6. x = np.arange(-5,5,0.01)
  7.  
  8.  
  9. def relu(x):
  10.     return [i if i>0 else 0 for i in x]
  11.  
  12.  
  13.  
  14. def softmax(x):
  15.     return np.exp(x) / np.sum(np.exp(x))
  16.  
  17.  
  18.  
  19. def sigmoid(x):
  20.     return 1/(1+np.exp(-x))
  21.    
  22. def tanh(x):
  23.     return (np.exp(x)-np.exp(-x))/(np.exp(x)+np.exp(-x))
  24.  
  25. soft = softmax([[1,2,3],[4,5,6]])
  26. print(soft)
  27. plt.plot(x,relu(x),'b')
  28.  
  29. plt.plot(x,sigmoid(x),'r')
  30. plt.plot(x,tanh(x),'g')
  31. plt.legend(["RelU","Softmax","sigmoid","tanh"])
  32. plt.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement