2021-12-04 13:55:42 +08:00
|
|
|
|
mindspore.ops.GeLU
|
|
|
|
|
|
==================
|
|
|
|
|
|
|
2022-11-19 10:12:44 +08:00
|
|
|
|
.. py:class:: mindspore.ops.GeLU
|
2021-12-04 13:55:42 +08:00
|
|
|
|
|
|
|
|
|
|
高斯误差线性单元激活函数(Gaussian Error Linear Units activation function)。
|
|
|
|
|
|
|
2022-01-12 20:35:30 +08:00
|
|
|
|
在 `Gaussian Error Linear Units (GELUs) <https://arxiv.org/abs/1606.08415>`_ 文章中对GeLU函数进行了介绍。
|
2021-12-04 13:55:42 +08:00
|
|
|
|
此外,也可以参考 `BERT: Pre-training of Deep Bidirectional Transformers for Language Understanding <https://arxiv.org/abs/1810.04805>`_ 。
|
|
|
|
|
|
|
|
|
|
|
|
GeLU函数定义如下:
|
|
|
|
|
|
|
|
|
|
|
|
.. math::
|
2021-12-22 11:46:09 +08:00
|
|
|
|
GELU(x_i) = x_i*P(X < x_i)
|
2021-12-04 13:55:42 +08:00
|
|
|
|
|
2021-12-22 11:46:09 +08:00
|
|
|
|
其中 :math:`P` 是标准高斯分布的累积分布函数, :math:`x_i` 是输入的元素。
|
2021-12-04 13:55:42 +08:00
|
|
|
|
|
2022-07-26 10:27:56 +08:00
|
|
|
|
输入:
|
|
|
|
|
|
- **x** (Tensor) - 激活函数GeLU的输入,数据类型为float16或float32。
|
2021-12-04 13:55:42 +08:00
|
|
|
|
|
2022-07-26 10:27:56 +08:00
|
|
|
|
输出:
|
|
|
|
|
|
Tensor,数据类型和shape与 `x` 的相同。
|
2021-12-04 13:55:42 +08:00
|
|
|
|
|
2022-07-26 10:27:56 +08:00
|
|
|
|
异常:
|
|
|
|
|
|
- **TypeError** - `x` 不是Tensor。
|
|
|
|
|
|
- **TypeError** - `x` 的数据类型既不是float16也不是float32。
|