Advertisement
pkowalecki

175IC_6.1

Dec 10th, 2019
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.68 KB | None | 0 0
  1. import numpy
  2. from matplotlib import pyplot
  3.  
  4. X = numpy.arange(-5,5,0.1)
  5.  
  6. # ReLU
  7. def ReLU(X):
  8.    return numpy.maximum(0,X)
  9. Y = ReLU(X);
  10. pyplot.plot(X,Y, c="blue")
  11.  
  12.  
  13. #Sigmoid
  14. def Sigmoid(X):
  15.   return 1/(1+numpy.exp(-X))
  16. Z = Sigmoid(X);
  17. pyplot.plot(X,Z, c="red")
  18.  
  19.  
  20. #Tanh
  21. def Tanh(X):
  22.   licznik = numpy.exp(X)-numpy.exp(-X)
  23.   mianownik = numpy.exp(X)+numpy.exp(-X)
  24.   return licznik/mianownik
  25. Z = Tanh(X)
  26. pyplot.plot(X, Z, c="green")
  27.  
  28. pyplot.show()
  29.  
  30. # Softmax
  31. M = numpy.array([[1,2,3], [4,5,6], [6,6,6]])
  32. x = numpy.array([1,2,3])
  33. x.T
  34. def Softmax(x):
  35.     expo = numpy.exp(x)
  36.     expo_sum = numpy.sum(numpy.exp(x))
  37.     return expo/expo_sum
  38. M = Softmax(x);
  39. print(M)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement