Programming/Python
GELU, Gaussian Error Linear Unit
HTleaf
2024. 11. 22. 08:19
- 최신 AI 모델에서 성능이 좋아 많이 사용되는, 2016년에 개발된 활성화 함수
$\sigma \to 0$이 되면 ReLU함수가 됨. 즉, ReLU의 smoothing version
- 모든 점에서 미분이 가능
- bounded below, unbounded above, non-monotonic, smooth
- x가 다른 입력에 비해 얼마나 큰지 비율로 gating
-> 확률적 해석(입력값 크기에 따라 가중치 조절), 미분 가능 형태
구현 방법(torch)
import torch
import torch.nn as nn
class DenseBlock(nn.Module):
def __init__(self, in_dim, out_dim):
super(DenseBlock, self).__init__()
self.dense = nn.Linear(in_dim, out_dim)
self.act = nn.GELU() # activation function
def forward(self, x):
out = self.act(self.dense(x))
return out
728x90
반응형