Gaussian Error Linear Unit Activates Neural Networks Beyond ReLU (GELU, ELU, RELU 비교글)

2020. 1. 5. 16:07관심있는 주제/Activation Function

728x90

https://medium.com/syncedreview/gaussian-error-linear-unit-activates-neural-networks-beyond-relu-121d1938a1f7

 

Gaussian Error Linear Unit Activates Neural Networks Beyond ReLU

Results of the various experiments show GELU consistently has the best performance compared with ReLU and ELU.

medium.com

GELU에 대해서 간단하게 알아보자

## Google Bert
def gelu(x):
    """Gaussian Error Linear Unit.
    This is a smoother version of the RELU.
    Original paper: https://arxiv.org/abs/1606.08415
    Args:
        x: float Tensor to perform activation.
    Returns:
        `x` with the GELU activation applied.
    """
    cdf = 0.5 * (1.0 + tf.tanh(
        (np.sqrt(2 / np.pi) * (x + 0.044715 * tf.pow(x, 3)))))
    return x * cdf
    
## OpenAI GPT-2
def gelu(x):
    return 0.5*x*(1+tf.tanh(np.sqrt(2/np.pi)*(x+0.044715*tf.pow(x, 3))))

https://mlfromscratch.com/tensorflow-2/#/

The Gaussian Error Linear Unit (GELU) activation function는 UC Berkeley’s Dan Hendrycks and Kevin Gimpel from the Toyota Technological Institute at Chicago에 의해서 2018년도에 도입되었다.

이 활성 함수는 neuron output을 야기하는 switch이다.  이것의 중요성은 네트워크가 깊어질수록 증가한다.
최근 GELU에 대해서 많은 관심을 가지고 있다.

초기의 인공 뉴런은 이진법 단위를 이용했다. 이 엄격한 binary decision은 sigmoid 활성화로 평준화될 수 있다. 그리고 뉴런은 "firing rate" 해석을 하고 역전파를 사용하여 훈련할 수 있었다.
RELU는 입력 부호에 기초한 게이트 결정의 특징 때문에 가장 인기 있는 활성화 기능이 되었다.

Hendrycks and Gimpel는 비선형성 함수인 GELU를 제안했다.
왜냐하면 그것은 adaptive dropout에 대한 수정된 기대로서, 뉴런의 출력이 더 높은 확률론적 관점을 제공하기 때문이다.

computer vision에서 NLP(natural language processing), 그리고 automatic speech recognition taks, GELU 활성화 기능을 사용하는 모델의 성능은 ReLU 또는 고급 버전 ELU(Exponential Linear Unit) 활성화 기능을 사용하는 모델의 성능과 비슷하거나 그 이상이다. GELU는 BERT, ROBERTa, ALBERT 및 기타 상위 NLP 모델과 호환된다.

GELU, RELU, ELU 활성 함수

MNIST 데이터로 비교하면 다음과 같다고 한다. 
fully connected neural network with GELUs (µ = 0, σ = 1), ReLUs, and ELUs (α = 1)
각각 8개의 Layer / 128 Neuron / 128 batch size

In the tests median error rate

GELU  ReLU  ELU 
7.89% 8.16% 8.41%

 

GELU  ReLU  ELU 
29.3% 29.5% 29.6%

 

The paper Gaussian Error Linear Units (GELUS) is on arXiv.

여러 가지 실험 결과에서 GELU가 다른 알고리즘들 보다 더 빠르게 수렴하고 있는 것을 알 수 있다.
(하지만 결국 Epoch 200 정도가 되면 거의 같은 Error 수준으로 떨어지기는 한 것 같다.)
결국 글쓴이는 GELU, ELU, RELU 중에서 GELU가 가장 좋다고 말하고 있다.

참고 

https://mlfromscratch.com/tensorflow-2/#/

728x90