일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | 7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 | 30 | 31 |
Tags
- SmoothGrad
- meta-learning
- Artificial Intelligence
- 설명가능한
- Class activation map
- 기계학습
- Score-CAM
- 메타러닝
- keras
- Interpretability
- AI
- 백준
- Cam
- coding test
- 인공지능
- Machine Learning
- grad-cam
- 코딩 테스트
- GAN
- Explainable AI
- Deep learning
- 머신러닝
- 딥러닝
- 설명가능한 인공지능
- 코딩테스트
- python
- cs231n
- 시계열 분석
- xai
- Unsupervised learning
Archives
- Today
- Total
iMTE
주요 기계학습, 딥러닝 activation function 본문
In [1]:
import matplotlib.pyplot as plt
import numpy as np
Step function¶
In [2]:
def step(x):
return 1*(x>0)
In [3]:
inputs = np.arange(-5,5,0.01)
outputs = step(inputs)
plt.figure(figsize=(8,5))
plt.plot(inputs,outputs,label='Step function')
plt.hlines(0,-5,5)
plt.vlines(0,0,1)
plt.xlabel('input',fontsize=24)
plt.ylabel('output',fontsize=24)
plt.grid(alpha=0.3)
plt.title("Step function",fontsize=24)
plt.legend(loc='upper left',fontsize=15)
plt.show()
Sigmoid¶
In [4]:
def sigmoid(x):
return 1./(1+np.exp(-x))
In [5]:
inputs = np.arange(-5,5,0.1)
outputs = sigmoid(inputs)
plt.figure(figsize=(8,5))
plt.plot(inputs,outputs,label='Sigmoid')
plt.hlines(0,-5,5)
plt.vlines(0,0,1)
plt.xlabel('input',fontsize=24)
plt.ylabel('output',fontsize=24)
plt.grid(alpha=0.3)
plt.title("Sigmoid",fontsize=24)
plt.legend(loc='upper left',fontsize=15)
plt.show()
ReLU¶
In [6]:
def relu(x):
return x * (x>0)
In [7]:
inputs = np.arange(-5,5,0.1)
outputs = relu(inputs)
plt.figure(figsize=(8,5))
plt.plot(inputs,outputs,label='Relu')
plt.hlines(0,-5,5)
plt.vlines(0,0,5)
plt.xlabel('input',fontsize=24)
plt.ylabel('output',fontsize=24)
plt.grid(alpha=0.3)
plt.title("ReLU",fontsize=24)
plt.legend(loc='upper left',fontsize=15)
plt.show()
tanh¶
In [8]:
def tanh(x):
return np.tanh(x)
In [9]:
inputs = np.arange(-5,5,0.1)
outputs = tanh(inputs)
plt.figure(figsize=(8,5))
plt.plot(inputs,outputs,label='Tanh')
plt.hlines(0,-5,5)
plt.vlines(0,-1,1)
plt.xlabel('input',fontsize=24)
plt.ylabel('output',fontsize=24)
plt.grid(alpha=0.3)
plt.title("Tanh",fontsize=24)
plt.legend(loc='upper left',fontsize=15)
plt.show()
Leaky ReLU¶
In [10]:
def leaky_relu(x):
return np.maximum(0.1*x,x)
In [11]:
inputs = np.arange(-5,5,0.1)
outputs = leaky_relu(inputs)
plt.figure(figsize=(8,5))
plt.plot(inputs,outputs,label='Leaky ReLU')
plt.hlines(0,-5,5)
plt.vlines(0,-1,5)
plt.xlabel('input',fontsize=24)
plt.ylabel('output',fontsize=24)
plt.grid(alpha=0.3)
plt.title("Leaky ReLU",fontsize=24)
plt.legend(loc='upper left',fontsize=15)
plt.show()
Exponential Linear Unit¶
In [12]:
def elu(x,a):
return x*(x>0)+a*(np.exp(x)-1)*(x<=0)
In [13]:
inputs = np.arange(-5,5,0.1)
outputs = elu(inputs,1)
plt.figure(figsize=(8,5))
plt.plot(inputs,outputs,label='ELU')
plt.hlines(0,-5,5)
plt.vlines(0,-1,5)
plt.xlabel('input',fontsize=24)
plt.ylabel('output',fontsize=24)
plt.grid(alpha=0.3)
plt.title("ELU",fontsize=24)
plt.legend(loc='upper left',fontsize=15)
plt.show()
Softplus¶
In [14]:
def softplus(x):
return np.log(np.exp(x)+1)
In [15]:
inputs = np.arange(-5,5,0.1)
outputs = softplus(inputs)
plt.figure(figsize=(8,5))
plt.plot(inputs,outputs,label='Softplus')
plt.hlines(0,-5,5)
plt.vlines(0,0,5)
plt.xlabel('input',fontsize=24)
plt.ylabel('output',fontsize=24)
plt.grid(alpha=0.3)
plt.title("Softplus",fontsize=24)
plt.legend(loc='upper left',fontsize=15)
plt.show()
Softsign¶
In [16]:
def softsign(x):
return x/(1+np.abs(x))
In [17]:
inputs = np.arange(-5,5,0.1)
outputs = softsign(inputs)
plt.figure(figsize=(8,5))
plt.plot(inputs,outputs,label='Softsign')
plt.hlines(0,-5,5)
plt.vlines(0,-1,1)
plt.xlabel('input',fontsize=24)
plt.ylabel('output',fontsize=24)
plt.grid(alpha=0.3)
plt.title("Softsign",fontsize=24)
plt.legend(loc='upper left',fontsize=15)
plt.show()
Swish¶
In [18]:
def swish(x):
return 1./(1+np.exp(-x))*x
In [19]:
inputs = np.arange(-5,5,0.1)
outputs = swish(inputs)
plt.figure(figsize=(8,5))
plt.plot(inputs,outputs,label='Swish')
plt.hlines(0,-5,5)
plt.vlines(0,-1,5)
plt.xlabel('input',fontsize=24)
plt.ylabel('output',fontsize=24)
plt.grid(alpha=0.3)
plt.title("Swish",fontsize=24)
plt.legend(loc='upper left',fontsize=15)
plt.show()
In [ ]:
Comments