tf.keras.ops.gelu
Функция активации Gaussian Error Linear Unit (GELU).
tf.keras.ops.gelu(
x, approximate=True
)
Если approximate равно True, оно определяется как: f(x) = 0.5 * x * (1 + tanh(sqrt(2 / pi) * (x + 0.044715 * x^3)))
Или если approximate равно False, оно определяется как: f(x) = x * P(X <= x) = 0.5 * x * (1 + erf(x / sqrt(2))), где P(X) ~ N(0, 1).
| Аргументы | |
|---|---|
x | Входной тензор. |
approximate | Приближенная версия активации GELU. По умолчанию равно True. |
| Возвращаемое значение | |
|---|---|
Тензор с той же формой, что и x. |
Пример:
x = np.array([-1., 0., 1.]) x_gelu = keras.ops.gelu(x) print(x_gelu) array([-0.15865525, 0., 0.84134475], shape=(3,), dtype=float64)
© 2022 The TensorFlow Authors. All rights reserved.
Licensed under the Creative Commons Attribution License 4.0.
Code samples licensed under the Apache 2.0 License.
https://www.tensorflow.org/api_docs/python/tf/keras/ops/gelu