python/신호및시스템 - python

[python] 신호 및 시스템 - 램프 함수

왜왜왜왜 2021. 7. 26. 01:50

 

 

머신러닝 쪽에서는 relu라고도 부릅니다.

 

import numpy as np
import matplotlib.pylab as plt 

t = np.arange(-5, 10, 0.01)
x = np.maximum(0, t)

plt.plot(t, x)
plt.show()

maximun() 함수는 두 개의 array에 대해 동일한 위치의 성분끼리 비교하여 최대값을 반환합니다.

t = np.arange(-5, 10, 0.01)
x = np.maximum(t+3, 0)

plt.plot(t, x)
plt.show()

t = np.arange(-5, 10, 0.01)
x = np.maximum(t+3, 0) - 2*np.maximum(t+2, 0) + np.maximum(t, 0) + np.maximum(t-3, 0) - + np.maximum(t-4, 0)

plt.plot(t, x)
plt.show()