Bigdata
Python - Gaussian Error Linear Unit (GELU) 수식 - 코드
올엠
2024. 8. 11. 07:36
반응형
Gaussian Error Linear Unit (GELU)의 activation 수식

Gaussian Distribution을 다음 수식으로 위 수식의 복잡도를 낮추어 아래와 같이 근사(Approximation) 수식을 활용한게 된다.

근사(Approximation) 수식을 코드로 구현하면 다음과 같다.
import math
import tensorflow as tf
cdf = 0.5 * (1.0 + tf.tanh( (math.sqrt (2 / math.pi) * (x + 0.044715 * tf.pow(x, 3)))))
반응형