Advertisement
Guest User

SI - Niewiarowska - lab6

a guest
Dec 10th, 2019
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.59 KB | None | 0 0
  1. from matplotlib import pyplot as plt
  2. import numpy as np
  3. import math
  4.  
  5. def ReLU(x):
  6.     return np.maximum(0, x)
  7.  
  8. def Sigmoid(x):
  9.     return 1.0 / (1 + np.exp(-x))
  10.  
  11. def Softmax(x):
  12.     expo = np.exp(x)
  13.     expo_sum = np.sum(np.exp(x))
  14.     return expo/expo_sum
  15.  
  16. def Tanh(x):
  17.     a = np.exp(x) - np.exp(-x)
  18.     b = np.exp(x) + np.exp(-x)
  19.     return a/b
  20.  
  21. d = 5
  22. x = np.arange(-d, d, step=0.1)
  23.  
  24. plt.plot(x, ReLU(x), color='red', label='ReLU')
  25. plt.plot(x, Sigmoid(x), color='green', label='Sigmoid')
  26. plt.plot(x, Tanh(x), color='blue', label='Tanh')
  27.  
  28. plt.grid()
  29. plt.legend()
  30. plt.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement